Help for RegEx

Can I have some help with regex.
I want to cut files like :

\1 must be digits
“ - “ is the separator (space minus space)
\2 must have all characters, but never “ - “ (space minus space)

01 - Toto - Tata.mp3
02 - 666.mp3
03 - Ti-ti Tata.mp3
04 - To-to.mp3
05 - Toto.mp3
06 - Toto Tata.mp3
07 - Toto666Tata.mp3
Toto - Tata.mp3

I turned on Ignore Extension but you can add the \.mp3 back if you don't want that.

^(\d+) - (?!.* - .*)(.*)$
\2\\\1

1 Like

Can you explain (?!.* - .*) please ?

It's a negative lookahead.

http://www.regular-expressions.info/lookaround.html
http://www.rexegg.com/regex-lookarounds.html

1 Like