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 (11)
`
^(?:\D+)?(?:(?:[5-6](?:(?:\.|\,)[1-9])?)|(?:[6-7](?:(?:\.|\,)0)?))(?:(?:\s?pol)|"|''|\x60|'|´|)?(?:.*)
`
s
^ asserts position at start of the string
Non-capturing group
(?:\D+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\D
matches any character that's not 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
(?:(?:[5-6](?:(?:\.|\,)[1-9])?)|(?:[6-7](?:(?:\.|\,)0)?))
1st Alternative
(?:[5-6](?:(?:\.|\,)[1-9])?)
Non-capturing group
(?:[5-6](?:(?:\.|\,)[1-9])?)
Match a single character present in the list below
[5-6]
5-6 matches a single character in the range between 5 (index 53) and 6 (index 54) (case sensitive)
Non-capturing group
(?:(?:\.|\,)[1-9])?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:\.|\,)
1st Alternative
\.
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
2nd Alternative
\,
\, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
Match a single character present in the list below
[1-9]
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case sensitive)
2nd Alternative
(?:[6-7](?:(?:\.|\,)0)?)
Non-capturing group
(?:[6-7](?:(?:\.|\,)0)?)
Match a single character present in the list below
[6-7]
6-7 matches a single character in the range between 6 (index 54) and 7 (index 55) (case sensitive)
Non-capturing group
(?:(?:\.|\,)0)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:\.|\,)
1st Alternative
\.
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
2nd Alternative
\,
\, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
Non-capturing group
(?:(?:\s?pol)|"|''|\x60|'|´|)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
(?:\s?pol)
Non-capturing group
(?:\s?pol)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
pol
matches the characters pol literally (case sensitive)
2nd Alternative
"
" matches the character " with index 3410 (2216 or 428) literally (case sensitive)
3rd Alternative
''
''
matches the characters '' literally (case sensitive)
4th Alternative
\x60
\x60 matches the character ` with index 6016 (9610 or 1408) literally (case sensitive)
5th Alternative
'
' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
6th Alternative
´
´ matches the character ´ with index 18010 (B416 or 2648) literally (case sensitive)
7th Alternative
matches the character with index 822110 (201D16 or 200358) literally (case sensitive)
Non-capturing group
(?:.*)
.
matches any character
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Global pattern flags
s modifier: single line. Dot matches newline characters
Your regular expression does not match the subject string.

Regular Expression
No Match

`
`
s

Test String