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
/
[A-Z]{2}\d[A-Z] \d[A-Z]{2}
/
i
Match a single character present in the list below
[A-Z]
{2} matches the previous token exactly 2 times
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case insensitive)
\d matches a digit (equivalent to [0-9])
Match a single character present in the list below
[A-Z]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
\d matches a digit (equivalent to [0-9])
Match a single character present in the list below
[A-Z]
{2} matches the previous token exactly 2 times
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case insensitive)
Global pattern flags
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

/
/
i

Test String