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
/
(?<![private|public|protected|static]\s)function\s.*?\(.*?\)\s?{
/
Negative Lookbehind
(?<![private|public|protected|static]\s)
Assert that the Regex below does not match
Match a single character present in the list below
[private|public|protected|static]
private|public|protected|static
matches a single character in the list private|ublcods (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
function
matches the characters function literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
\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)
{ matches the character { with index 12310 (7B16 or 1738) literally (case sensitive)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String