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
/
e([bngr][odbp]?[poy]){2}
/
gi
e matches the character e with index 10110 (6516 or 1458) literally (case insensitive)
1st Capturing Group
([bngr][odbp]?[poy]){2}
{2} matches the previous token exactly 2 times
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
Match a single character present in the list below
[bngr]
bngr
matches a single character in the list bngr (case insensitive)
Match a single character present in the list below
[odbp]
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
odbp
matches a single character in the list odbp (case insensitive)
Match a single character present in the list below
[poy]
poy
matches a single character in the list poy (case insensitive)
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