Regular Expressions 101

Community Patterns

Chords

1

Regular Expression
ECMAScript (JavaScript)

/
\b(?:G,C,D|A,B,C|E,C,D)|(?:[ABCDEFG](?:#|b)?)(?:\/[ABCDEFG]b)?(?:(?:(?:maj|min|sus|add|aug|dim)(?:\d{0,2}(?:#\d{1,2}|sus\d)?)?)|(?:m\d{0,2}(?:(?:maj|add|#)\d{0,2})?)|(?:-?\d{0,2}(?:\([^)]*\)|#\d{1,2})?))?
/
g

Description

Expression to match a large amount of possible musical chords. From what I understand from musicians, the number of chords is basically infinite, but you will still find a certain scope being used freuently.

Submitted by A=B - 9 years ago