modularbeing Posted February 9, 2005 Posted February 9, 2005 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 Quote
John_0025 Posted February 9, 2005 Posted February 9, 2005 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. ((\d+)|(\d+\s+))\-(.*)\.(([wW][mM][aA])|([mM][pP][3])) Quote
modularbeing Posted February 9, 2005 Author Posted February 9, 2005 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. ((\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 Quote
modularbeing Posted February 9, 2005 Author Posted February 9, 2005 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. ((\d+|\d+\s+)-(.*).([wW][mM][aA])|([mM][pP][3])) thanks again! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.