Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any regex pros for a tiny problem?
Message
De
08/09/2006 20:29:48
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Any regex pros for a tiny problem?
Divers
Thread ID:
01152495
Message ID:
01152495
Vues:
76
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!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform