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
/
Jude ?\d{1,3}:\d{1,3}(-\d{1,3})?\b|\bjud ?\d{1,3}:\d{1,3}(-\d{1,3})?\b|\bjd ?\d{1,3}:\d{1,3}(-\d{1,3})?\b
/
gmi
1st Alternative
Jude ?\d{1,3}:\d{1,3}(-\d{1,3})?\b
Jude
matches the characters Jude literally (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
: matches the character : with index 5810 (3A16 or 728) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
1st Capturing Group
(-\d{1,3})?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
2nd Alternative
\bjud ?\d{1,3}:\d{1,3}(-\d{1,3})?\b
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
jud
matches the characters jud literally (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
: matches the character : with index 5810 (3A16 or 728) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
(-\d{1,3})?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
3rd Alternative
\bjd ?\d{1,3}:\d{1,3}(-\d{1,3})?\b
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
jd
matches the characters jd literally (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
: matches the character : with index 5810 (3A16 or 728) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
3rd Capturing Group
(-\d{1,3})?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
- matches the character - with index 4510 (2D16 or 558) literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{1,3} matches the previous token between 1 and 3 times, as many times as possible, giving back as needed (greedy)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
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

/
/
gmi

Test String