Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Removing text after a character (Read 1847 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Removing text after a character

If I have track titles such as (for example)

Blah, blah, blah -aria
Bleah, bleah -chorus
Beugh, bleugh -cavatina

...is there a way to get Foobar2K/Masstagger to remove all text after the minus sign (the hyphen), including the hyphen itself, and the space before it? In other words, I want to be left with just

Blah, blah, blah
Bleah, bleah
Beugh, bleugh

I've experimented with the cut function, but I'm having no joy. Whatever track editing function I use has to be able to spot the use of a particular character ("-" in this case), and trim the track title from that point on, backing up a character for good measure.

I'm certain it can be done, but my string manipulation function-writing is just not up to it at this point.

Hoping someone will sniff that this sort of thing is as easy as pie, and be prepared to share the basic secret...

Regards
HJR

Removing text after a character

Reply #1
Code: [Select]
$left(%your_field_here%,$sub($strrchr(%your_field_here%,-),2))
f to c to f to c

 

Removing text after a character

Reply #2
Thank you so much. That does the job very nicely.

I needed it to strip out closing single quotation marks, amongst other things, and I found that I needed to write it as

   
$left(%title%,$sub($strrchr(%title%,''),2))

(ie, two repeated single quotation marks towards the end).

Other than that specific peculiarity, it works exactly as advertised, so thanks once again.

Regards
HJR