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
/
(\d+)(?=м\b|\s+метров)
/
iug
1st Capturing Group
(\d+)
\d
matches a digit zero through nine in any script except ideographic scripts (equivalent to \p{Nd})
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Positive Lookahead
(?=м\b|\s+метров)
Assert that the Regex below matches
1st Alternative
м\b
м matches the character м with index 108410 (43C16 or 20748) literally (case insensitive)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
2nd Alternative
\s+метров
\s
matches any kind of invisible character (equivalent to [\p{Z}\h\v])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
метров
matches the characters метров literally (case insensitive)
Global pattern flags
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
u modifier: unicode. Pattern strings are treated as UTF-16. Also causes escape sequences to match unicode characters
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
iug

Test String

Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php