PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 30, 2021

[FIXED] PHP regex to find CR 3492161 or cr 3492161

 December 30, 2021     cakephp, php, reference, regex, yii     No comments   

Issue

I am trying a PHP regex to find CR 3492161 or cr 3492161. I have tried using the following regex however it is not working. Requesting your help. :-)

'CR\s/^\d{7}$/'
'CR\h/^\d{7}$/'
'CR /^\d{7}$/'

Note : CR is not a Carriage return, perhaps it is just a Pattern CR.

Code :

<?php
namespace Shedanigans;
use Application\Filter\Linkify;
class Module
{
  public function onBootstrap()
  {
    Linkify::addCallback(
      function ($value, $escaper) {
        if (strcasecmp($value, 'CR\s/^\d{7}$/')) {
          // not a hit; tell caller we did not handle this one
          return false;
        }
        return '<a target="_new" href="https://xtz.abc.com/">'
               . $escaper->escapeHtml($value) . "</a>";
       },
      'CR\s/^\d{7}$/',
      strlen('CR\s/^\d{7}$/')
    );
  }
    public function getConfig()
    {
    return array();
    }
  }

Solution

You could try this:

(?:CR|cr)\s[0-9]{7}

Regular expression visualization

Debuggex Demo



Answered By - Ron van der Heijden
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing