Merge duplicate words

Hi,

I would like to find in genre duplicate words and merge them together.

This is an example of genre tag:

Before

AFRICA; AFRICA; NATURAL WORLD; NATURE STUDY; NATURE; DRAMA ADVENTURE; DRAMA WORLD; PERCUSSION; INSTRUMENTS SOLO PERCUSSION; WILDLIFE MOVEMENT; DRAMA ADVENTURE; AFRICA; FILM STYLES ANCIENT ROME; AFRICA

After

AFRICA;  NATURAL WORLD; NATURE STUDY; NATURE; DRAMA WORLD; PERCUSSION; INSTRUMENTS SOLO PERCUSSION; WILDLIFE MOVEMENT; DRAMA ADVENTURE;  FILM STYLES ANCIENT ROME

; is the separator here
[A-Z ]*; I think will match every entry for this songs genre

AFRICA is for instance 4 times repeated and I would like to merge them into 1 time
DRAMA ADVENTURE is twice repeated

Is there a way to do this?

Kind regards
Guy Forssman

Search there ...
https://www.google.de/search?q=site%3Aforum...p;oq=&gs_l=

Read there ...
Doppelte Genre löschen

DD.20141103.1721.CET

You want to keep the first value. That's more complicated.

[Edit:]
Action: Format value
Field: Genre
Format string: $regexp($reverse($regexp($regexp($reverse($regexp($regexp(%Genre%,'^(\s+;|\s;+)+|(\s+;|\s;+)+$|((?<=;)\s+)|(\s+(?=;))',),'^|$',';')),'(;[^;]+)(?=(\1|;.*?\1))',),'^;+|;+$',)),'(?<=;)',' ')

Replace Genre with any other tag and it will remove duplicates too.
This action "fixes" first the multiple value string (remove multiple spaces after ; separator).
It will add exactly one space after value separator [;].

Enjoy. :wink:

Hi I apreciate your answer as yesterday I couldn't search ...
Your type of answer will motivate me to search in the next time even better, if I can find it I'm helped immediately :slight_smile:

Thank you for your patience with me
Guy Forssman

Hi,

Thank you very much,
I have tried it and it works like a charm..
Indeed I will be using it for mood tag to.

This one could definitely be in the list of examples of reg expressions.

Hartelijk bedankt
Guy Forssman :w00t:

Hi There,

On some longer metadata fields I get this error REGEXP ERROR: Regular expression

The complexity of matching the regular expression exceeded predefined bounds.  Try refactoring the regular expression to make each choice made by the state machine unambiguous.  This exception is thrown to prevent "eternal" matches that take an indefinite period time to locate.

I found a workaround by eliminating excessive ; signs

Thanks again

QUOTE (ForSSOund @ Nov 28 2014, 11:21) <{POST_SNAPBACK}>
Hi There,

On some longer metadata fields I get this error REGEXP ERROR: Regular expression

The complexity of matching the regular expression exceeded predefined bounds.  Try refactoring the regular expression to make each choice made by the state machine unambiguous.  This exception is thrown to prevent "eternal" matches that take an indefinite period time to locate.

I found a workaround by eliminating excessive ; signs

Thanks again


Simplified version.
$reverse($regexp($regexp(';'$reverse(%Genre%),'\s*(;[^;]+)(?=(\s*\1|;.?\1))',),'^\s;+|;+\s*$',))