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
/
(^((feature|bugfix)\/[A-Z]+-\d+)|^(release\/(R2\d)(-)\d{2}.\d.\d))([a-z-]+)?
/
gm
1st Capturing Group
(^((feature|bugfix)\/[A-Z]+-\d+)|^(release\/(R2\d)(-)\d{2}.\d.\d))
1st Alternative
^((feature|bugfix)\/[A-Z]+-\d+)
^ asserts position at start of a line
2nd Capturing Group
((feature|bugfix)\/[A-Z]+-\d+)
3rd Capturing Group
(feature|bugfix)
1st Alternative
feature
feature
matches the characters feature literally (case sensitive)
2nd Alternative
bugfix
bugfix
matches the characters bugfix literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
Match a single character present in the list below
[A-Z]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Alternative
^(release\/(R2\d)(-)\d{2}.\d.\d)
^ asserts position at start of a line
4th Capturing Group
(release\/(R2\d)(-)\d{2}.\d.\d)
release
matches the characters release literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
5th Capturing Group
(R2\d)
R2
matches the characters R2 literally (case sensitive)
\d matches a digit (equivalent to [0-9])
6th Capturing Group
(-)
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
. matches any character (except for line terminators)
\d matches a digit (equivalent to [0-9])
. matches any character (except for line terminators)
\d matches a digit (equivalent to [0-9])
7th Capturing Group
([a-z-]+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[a-z-]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
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)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String