Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
(?:[^@`]|\s+|^)(?:love|luv)\s?(?:u|you|me)?,?\s?(?:cbot|@?camperbot)
/
ig
Non-capturing group
(?:[^@`]|\s+|^)
1st Alternative
[^@`]
Match a single character not present in the list below
[^@`]
@`
matches a single character in the list @` (case insensitive)
2nd Alternative
\s+
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
3rd Alternative
^
^ asserts position at start of the string
Non-capturing group
(?:love|luv)
1st Alternative
love
love
matches the characters love literally (case insensitive)
2nd Alternative
luv
luv
matches the characters luv 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)
Non-capturing group
(?:u|you|me)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
u
u matches the character u with index 11710 (7516 or 1658) literally (case insensitive)
2nd Alternative
you
you
matches the characters you literally (case insensitive)
3rd Alternative
me
me
matches the characters me literally (case insensitive)
,
matches the character , with index 4410 (2C16 or 548) 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)
Non-capturing group
(?:cbot|@?camperbot)
1st Alternative
cbot
cbot
matches the characters cbot literally (case insensitive)
2nd Alternative
@?camperbot
@
matches the character @ with index 6410 (4016 or 1008) literally (case insensitive)
camperbot
matches the characters camperbot literally (case insensitive)
Global pattern flags
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
ig

Test String