I’m using a software to edit songs using regular expressions. This is what I have:
Jimmy Eat World – The Middle (.mp3)
What I would like to do is delete the space before the “-” and everything after, so I would just be left with “Jimmy Eat World”
And the other action that I would like to perform is to delete everything up to the “-” and the space following so I’d be left with just “The Middle”
That’s an easy one.
First action – Remove anything after the dash:
/ -.*/with the empty string. (Note there’s an actual space before the dash.)/ +-.*/(again with an actual space before the+).Second action – Remove anything up to the dash:
/.* - /with the empty string. (Note there’s an actual space after the dash.)Notes
/above are not part of the regex, you won’t have to type them. They serve as a visual delimiter here..means “any character” (except newlines, which you won’t have anyway in filenames)*means “the previous item, zero to any number of times”+means “the previous item, at least once, possibly any number of times”^,$,.,+,*,?,{,},(,),[,],|and\, which have their own special meaning but are of no deeper concern in your situation.