problem with expression

modularbeing

Regular
Joined
Jan 8, 2004
Messages
63
Im having troubles getting this expression to work. The bolded part of the expression below needs to match anything which I thought a period was used for but its not working out.

(\d+|\d+\s+)-([.*]).([wW][mM][aA])|([mM][pP][3])

btw, im trying to match strings like:

12-mysong.wma
12 - my song.mp3
1 -my-song's.wma

thanks,
josh
 
You shouldn't have the '.*' in the square brackets. Also . and - are special characters so you need the backslash before them to use them normally try.

Code:
((\d+)|(\d+\s+))\-(.*)\.(([wW][mM][aA])|([mM][pP][3]))
 
John_0025 said:
You shouldn't have the '.*' in the square brackets. Also . and - are special characters so you need the backslash before them to use them normally try.

Code:
((\d+)|(\d+\s+))\-(.*)\.(([wW][mM][aA])|([mM][pP][3]))


thanks! this works nicely but i had one question. When I tested it at regexlib.com and i look at the match I see 12 and wma in there twice and a value for each space before and after the '-'.

I tested using: 12- my song's.wma

thanks again
 
modularbeing said:
thanks! this works nicely but i had one question. When I tested it at regexlib.com and i look at the match I see 12 and wma in there twice and a value for each space before and after the '-'.

I tested using: 12- my song's.wma

thanks again

ahh nevermind i fixed it, once i figured out grouping ahah This is what I did to get it to group how i want.
Code:
((\d+|\d+\s+)-(.*).([wW][mM][aA])|([mM][pP][3]))

thanks again!
 
Back
Top