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{1,2})(:")(['a-z]*)(",)
/
g
1st Capturing Group
(\S{1,2})
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
{1,2} matches the previous token between 1 and 2 times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
(:")
:"
matches the characters :" literally (case sensitive)
3rd Capturing Group
(['a-z]*)
Match a single character present in the list below
['a-z]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
4th Capturing Group
(",)
",
matches the characters ", literally (case sensitive)
Global pattern flags
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

/
/
g

Test String

Substitution

Processing...