Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any regex pros for a tiny problem?
Message
De
09/09/2006 17:49:18
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
09/09/2006 13:12:10
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01152495
Message ID:
01152582
Vues:
23
>>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!
>
>Keith,
>
>No testing, but have a go at this
>
>^([A-G][1-6][-#b]?(:(1|2|4|8|16|32)[.t]?)?)$
>
Thank you Gregory, it works well!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform