Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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]))

Posted
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

Posted
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!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...