Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
(\s|\()like(\s|\))\s*\(('((\w|%|'{2})]*)')\s*\+\s?@p\d+\s*\+('%')\)
/
gi
1st Capturing Group
(\s|\()
1st Alternative
\s
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
2nd Alternative
\(
\( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
like
matches the characters like literally (case insensitive)
2nd Capturing Group
(\s|\))
1st Alternative
\s
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
2nd Alternative
\)
\) matches the character ) with index 4110 (2916 or 518) literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
3rd Capturing Group
('((\w|%|'{2})]*)')
' matches the character ' with index 3910 (2716 or 478) literally (case insensitive)
4th Capturing Group
((\w|%|'{2})]*)
5th Capturing Group
(\w|%|'{2})
1st Alternative
\w
\w matches any word character (equivalent to [a-zA-Z0-9_])
2nd Alternative
%
% matches the character % with index 3710 (2516 or 458) literally (case insensitive)
3rd Alternative
'{2}
'
matches the character ' with index 3910 (2716 or 478) literally (case insensitive)
]
matches the character ] with index 9310 (5D16 or 1358) literally (case insensitive)
' matches the character ' with index 3910 (2716 or 478) literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\+ matches the character + with index 4310 (2B16 or 538) literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
@p
matches the characters @p literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\+ matches the character + with index 4310 (2B16 or 538) literally (case insensitive)
6th Capturing Group
('%')
'%'
matches the characters '%' literally (case insensitive)
\) matches the character ) with index 4110 (2916 or 518) literally (case insensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gi

Test String