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
"
(\A|[^*/])(-?\d+(?:\.\d+)?)([+-])(\d+(?:\.\d+)?)(\Z|[^*/])
"
1st Capturing Group
(\A|[^*/])
1st Alternative
\A
\A asserts position at start of the string
2nd Alternative
[^*/]
Match a single character not present in the list below
[^*/]
*/
matches a single character in the list */ (case sensitive)
2nd Capturing Group
(-?\d+(?:\.\d+)?)
-
matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
\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
(?:\.\d+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
\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)
3rd Capturing Group
([+-])
Match a single character present in the list below
[+-]
+-
matches a single character in the list +- (case sensitive)
4th 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)
Non-capturing group
(?:\.\d+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
\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)
5th Capturing Group
(\Z|[^*/])
1st Alternative
\Z
\Z asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
2nd Alternative
[^*/]
Match a single character not present in the list below
[^*/]
*/
matches a single character in the list */ (case sensitive)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"

Test String