PDA

View Full Version : VBScript RegEx for Guitar Chords


jessegavin
02-16-2005, 06:32 PM
I made a regular expression to match Guitar Chords.

[A-G](#|b)?([a-z]|[0-9])*

This pattern should find any of the following:

1) G
2) Gmaj
3) G7
4) G#
5) Gb
6) G#min

The pattern works for all of these except for #4. For some reason it will only return the 'G' instead of the full 'G#'. I find this very odd because if the chord is 'Gb', the regex will return the full 'Gb'.

This pattern works fine in javascript. Is there anything special with the '#' character in RegEx for VBScript? I am using VBscript engine 5.6

Thanks for any help.

jessegavin
02-16-2005, 09:00 PM
Found the answer:

([A-G](#|b)*([a-z]|[0-9])*)(/[A-G](#|b)*([a-z]|[0-9])*)*

This also accounts for chords with a '/' like: 'D/F#'