I'm making a program about music chords. The first character has to be a single letter A through G. The second letter can contain an optional either "#", "b" or "" (nothing at all). And then I want a capital M followed by a 7.
For example, in one of my boolean statements I want "AM7" and "F#M7" to both evaluate to true, for both being a major chord in music theory.
Would this be something like:
/([A-G]{#b''}{M7})/$.test("GbM7"); //Should be true
/([A-G]{#b''}{M7})/$.test("GbbM7"); //Should be false
/([A-G]{#b''}{M7})/$.test("Gbm7"); //Should be false
I know the code above is wrong, but I am trying to illustrate my throught process of what i am going for. I feel like I am really close.
Thanks for any help!
{ }groups do?[b#]?$after the regexp for?