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
/
(weighted[^0-9]+share[^4-9]+)(\s[0-9]+,\d\d.+)\s([0-9]+,\d\d.+)\n
/
gmi
1st Capturing Group
(weighted[^0-9]+share[^4-9]+)
weighted
matches the characters weighted literally (case insensitive)
Match a single character not present in the list below
[^0-9]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
share
matches the characters share literally (case insensitive)
Match a single character not present in the list below
[^4-9]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
4-9 matches a single character in the range between 4 (index 52) and 9 (index 57) (case insensitive)
2nd Capturing Group
(\s[0-9]+,\d\d.+)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
Match a single character present in the list below
[0-9]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
, matches the character , with index 4410 (2C16 or 548) literally (case insensitive)
\d matches a digit (equivalent to [0-9])
\d matches a digit (equivalent to [0-9])
.
matches any character (except for line terminators)
+ 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 ])
3rd Capturing Group
([0-9]+,\d\d.+)
Match a single character present in the list below
[0-9]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
, matches the character , with index 4410 (2C16 or 548) literally (case insensitive)
\d matches a digit (equivalent to [0-9])
\d matches a digit (equivalent to [0-9])
.
matches any character (except for line terminators)
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
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)
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

/
/
gmi

Test String