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
"
(?:.*\(.*)(\+|-{1})(?: )(\d+\.*?\d+)(?:.*\))
"
gi
Non-capturing group
(?:.*\(.*)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
1st Capturing Group
(\+|-{1})
1st Alternative
\+
\+ matches the character + with index 4310 (2B16 or 538) literally (case insensitive)
2nd Alternative
-{1}
-
matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
Non-capturing group
(?: )
matches the character with index 3210 (2016 or 408) literally (case insensitive)
2nd Capturing Group
(\d+\.*?\d+)
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\.
matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:.*\))
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\) matches the character ) with index 4110 (2916 or 518) literally (case insensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
gi

Test String

Substitution

Processing...