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
/
([CDEFGAB](#|##|b|bb)?)((M|m|aug|dim|sus|add)?(6|7|9|11|13|-5|\+5)?)
/
g
1st Capturing Group
([CDEFGAB](#|##|b|bb)?)
Match a single character present in the list below
[CDEFGAB]
CDEFGAB
matches a single character in the list CDEFGAB (case sensitive)
2nd Capturing Group
(#|##|b|bb)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
#
# matches the character # with index 3510 (2316 or 438) literally (case sensitive)
2nd Alternative
##
##
matches the characters ## literally (case sensitive)
3rd Alternative
b
b matches the character b with index 9810 (6216 or 1428) literally (case sensitive)
4th Alternative
bb
bb
matches the characters bb literally (case sensitive)
3rd Capturing Group
((M|m|aug|dim|sus|add)?(6|7|9|11|13|-5|\+5)?)
4th Capturing Group
(M|m|aug|dim|sus|add)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
M
M matches the character M with index 7710 (4D16 or 1158) literally (case sensitive)
2nd Alternative
m
m matches the character m with index 10910 (6D16 or 1558) literally (case sensitive)
3rd Alternative
aug
aug
matches the characters aug literally (case sensitive)
4th Alternative
dim
dim
matches the characters dim literally (case sensitive)
5th Alternative
sus
sus
matches the characters sus literally (case sensitive)
6th Alternative
add
add
matches the characters add literally (case sensitive)
5th Capturing Group
(6|7|9|11|13|-5|\+5)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
6
6 matches the character 6 with index 5410 (3616 or 668) literally (case sensitive)
2nd Alternative
7
7 matches the character 7 with index 5510 (3716 or 678) literally (case sensitive)
3rd Alternative
9
9 matches the character 9 with index 5710 (3916 or 718) literally (case sensitive)
4th Alternative
11
11
matches the characters 11 literally (case sensitive)
5th Alternative
13
13
matches the characters 13 literally (case sensitive)
6th Alternative
-5
-5
matches the characters -5 literally (case sensitive)
7th Alternative
\+5
\+ matches the character + with index 4310 (2B16 or 538) literally (case sensitive)
5 matches the character 5 with index 5310 (3516 or 658) literally (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
g

Test String