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
/
,[\n\s\t]*(?=[}\]])
/
gm
, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
Match a single character present in the list below
[\n\s\t]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\t matches a tab character (ASCII 9)
Positive Lookahead
(?=[}\]])
Assert that the Regex below matches
Match a single character present in the list below
[}\]]
} matches the character } with index 12510 (7D16 or 1758) literally (case sensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String

Substitution

Processing...