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"
Remove Text After a Character Using Find and Replace Copy and Paste the data from column A to column B (this is to keep the original data as well) With the cells in Column B selected, click on the Home tab. In the Editing group, click on the Find & Select option.
In this case, to remove all before the > character, just search for "*> " (without the quotes) and replace with nothing. Then all characters before "> " are removed. The opposite is also easy. To remove everything after the > character, just search for ">*" (without the quotes) and replace with nothing.
To get text following a specific character, you use a slightly different approach: get the position of the character with either SEARCH or FIND, subtract that number from the total string length returned by the LEN function, and extract that many characters from the end of the string.
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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With