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
/
(ncc|nx)\D?(\d*)
/
gi
1st Capturing Group
(ncc|nx)
1st Alternative
ncc
ncc
matches the characters ncc literally (case insensitive)
2nd Alternative
nx
nx
matches the characters nx literally (case insensitive)
\D
matches any character that's not a digit (equivalent to [^0-9])
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
(\d*)
\d
matches a digit (equivalent to [0-9])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
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.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gi

Test String

Regex Debugger

Please wait while your expression is being debugged...