Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any regex pros for a tiny problem?
Message
From
08/09/2006 20:29:48
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Any regex pros for a tiny problem?
Miscellaneous
Thread ID:
01152495
Message ID:
01152495
Views:
75
Howdy!

I'm having some trouble coming up with a regex matching expression for a small string format:
C3#:4.
-or-
F4-:16t
-or-
E2b
These represent musical notes.

"C" is the base note (A - G, uppercase only).
"3" is the octave (1 - 6).
"#" is the accidental (optional: can be "#" sharp, "b" flat, "-" natural, or "" omitted).
":" is required if anything follows...
"4" is the duration (1 whole, 2 half, 4 quarter, 8 eighth, 16 sixteenth, 32 thirtysecond)
"." is the duration modifier (optional: can be "." dotted, "t" triplet, or "" omitted)

So the first char must be [A-G] and the second char must be [1-6]. After this it gets a little hairy. The accidental is optional, so it's possible to have the colon immediately follow the octave digit. If there is a colon, then there must be a duration digit and there cannot be a duration modifier without a duration digit.

Thanks!
Next
Reply
Map
View

Click here to load this message in the networking platform