Remove first character but not next one of same type

A swapping-ground for Regular Expression syntax

Remove first character but not next one of same type

Postby navic99 » Sun Jul 29, 2007 8:32 pm

The filename looks like this:

- something - something.mp3

I just want to remove the first "-" but I want to leave the 2nd one. I can remove leading characters to do this, but not all the filenames are equal...some have the "-" and some don't, some have other leading characters, etc. I know this is simple!...just can't figure it out....
navic99
 
Posts: 1
Joined: Sun Jul 29, 2007 7:57 pm

Postby Stefan » Sun Jul 29, 2007 9:26 pm

> - something - something.mp3

Split your name into parts you want and you don't
and group the single search parts with ():



You search for "- " .................. use (- ) to search an dash followed by an blank. Refer to this group by using \1 as replacement.
followed by "something"........... use (.+) to search one or more of 'any char/sign'. Refer to this with \2
followed by " - " ...................... use ( - ) to search 'balnk space blank'. Refer to this with \3
followed by "something" ........... use (.+) again, Refer to this with \4
Not from interests here: .mp3"

Search: (- )(.+)( - )(.+)

Now replace only with them what you want

Replace: \2\3\4


See here for more help
http://www.bulkrenameutility.co.uk/Foru ... ic.php?t=5
http://www.bulkrenameutility.co.uk/Foru ... c.php?t=27
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions