Remove all text after specific character(s)

Hey all!

I'm searching around, and probably just missing something.

So I'd like to cut all text to the right of a defined character.

Example:

My genre field has w/o quotes "Folk Rock\\Another\\A Third"

I want to make it so that genre field reads "Folk Rock".

I want to remove all text to the right before the first "".

Hoping to get some guidance!

Thanks!

It looks like as you want to reduce a multi-value tag-field GENRE to a standard single-value tag-field GENRE, while keeping the first value item from the multi-value tag-field GENRE.

You can try this ...
Converter: "Tag - Tag" or Action: "Format value"
Field: GENRE
Format string: $regexp($meta_sep(GENRE,';'),'^(.+?);.*$','$1\\')
... or simpler ...
Format string: $meta(GENRE,0)'\\'

From:
(multi-value)
GENRE=Folk Rock
GENRE=Another
GENRE=A Third
To:
(single-value)
GENRE=Folk Rock

See also this bug note ...
/t/12626/1

DD.20130131.1119.CET

That did it! Thanks a ton!

May as well throw another out then. My publisher field doesn't appear to be a multi-value tag-field like my genre field was in the original post. My publisher field has multiple publisher's as well, yet in a single value, and I'd like to cut that down to the first one listed. Since we're not dealing with multi-value tag-fields, I need a different approach.

So, example layout of my publisher field:

Columbia; Columbia Records; A Third; A Fourth

So, each entry is separated by a semicolon.

I'd like the results to look like:

Columbia

So once again, I'd like to cut all text to the right of the semicolon, along with that semicolon.

I have a two step action, one to remove all text to the right of the semicolon, and another after that to actually just replace the semicolon with nothing:

Action type: Replace with regular expressions
Field: PUBLISHER
Regular expression: ^(.+;\s)(.+)
Replace matches with:$1

Then just a simple replace with blank to remove the lasting semicolon.

I'm sure there's an easier way to do this. If not, let me know!

Thanks again!

Have a closer look to the content of the tag-field:
each entry is separated by a string of one semicolon plus one space.

There are several ways to reach the goal.

  1. You may use the proposal no. 1 from post #2.
    Converter: "Tag - Tag" or Action: "Format value"
    Field: PUBLISHER
    Format string: $regexp($meta_sep(PUBLISHER,';'),'^(.+?);.*$','$1\\')

  2. You may use the regexp part only of proposal no. 1.

$regexp(%PUBLISHER%,'^(.+?);.*$','$1')

... or ...

$regexp(%PUBLISHER%,'^(.+?)(?:;\s*.+$|$)','$1')
  1. You may use a two step actions group.

Action: Split field by separator
Field: PUBLISHER
Separator: ;
Note: there is one semicolon only, there is no need to specify the space too.
Note: surrounding spaces will be trimmed automatically.

Action: Format value
Field: PUBLISHER
Format string: $meta(PUBLISHER,0)'\\'

DD.20130202.0503.CET

Once again, tremendous!

Last thing, is there any documentation that describes how this code is put together? The Mp3tag site doesn't go into a lot of depth, and I'd like to know how to do that instead of asking for a copy/paste solution on these forums.

Probably another silly question, but you've been great!

Thanks a lot!

I have a same problem, I think.

My Title is TEWS: Over the moon: 1 Feb 2013

I'd like the results to look like:

Over the moon.

I love this program but it the string seem hard to me.

Try an action of the type "Import field (guess values) for TITLE
Enter as mask:
%dummy%: %title%:%dummy%

Works only with titles that have two : in it.

Thanks a lot, :slight_smile:

I edited your guidance a little bit and it work like a champ, it already did.
I really appreciate your help. :smiley:

3 posts were split to a new topic: Extract artist from existing field