Remove first instance of a hyphen -

A swapping-ground for Regular Expression syntax

Remove first instance of a hyphen -

Postby eclipsedj » Tue Dec 14, 2010 11:52 pm

I need to remove the first instance of a hyphen in a filename so...

It changes from this...

AB12345 - 01 - Artist - Title.mp3

to this...

AB1234501 - Artist - Title

I'm assuming it is a regualr expression, but have no idea...HELP PLEASE!!!

Thanks!
eclipsedj
 
Posts: 2
Joined: Tue Dec 14, 2010 11:47 pm

Re: Remove first instance of a hyphen -

Postby DefAnt » Thu Dec 30, 2010 4:43 pm

Try using this expression as a test on a single file.

Match:
(.*\d*) - \d ( - .* - .*)
Replace:
\1\2

Grouping 1 aka \1 (.*\d*)
This will be needed to changed based on what this is. I put both the .* for lettering and \d* for numbering but you will have to fine tune that part to match what your files actually contain.

- \d
Will remove the first hyphen and the 01 number you put in your example.

( - .* - .*)
This one will grab everything else according to your example.
Hyphen, .* grabs artist, Hyphen again, .* grabs title.


Hope this helps.
DefAnt
 
Posts: 16
Joined: Tue Sep 14, 2010 7:28 pm
Location: New Jersey, USA


Return to Regular Expressions