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
/
^(?=.{2}(.))(?=.{5}(.))(?=.{7}(.))
/
^ asserts position at start of the string
Positive Lookahead
(?=.{2}(.))
Assert that the Regex below matches
.
matches any character (except for line terminators)
{2} matches the previous token exactly 2 times
1st Capturing Group
(.)
. matches any character (except for line terminators)
Positive Lookahead
(?=.{5}(.))
Assert that the Regex below matches
.
matches any character (except for line terminators)
{5} matches the previous token exactly 5 times
2nd Capturing Group
(.)
. matches any character (except for line terminators)
Positive Lookahead
(?=.{7}(.))
Assert that the Regex below matches
.
matches any character (except for line terminators)
{7} matches the previous token exactly 7 times
3rd Capturing Group
(.)
. matches any character (except for line terminators)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String