Regular Expressions

Switches first and last names

Thank you!
I developed it a little.

Variant A
It will not change those artists, where the conversion already done (artist has comma).
Example: Brel, Jacques William remains Brel, Jacques William

Action: regular expression
Field: ARTIST
Regular expression: ^([^,]+)\s([^,]+)$
Replace with: $2, $1

Variant B
It handles multipled for WMP artists (in format "artist1/artist2/artist3"), possible nicknames at the end in square brackets and trims unnecessary white spaces.

Example:
Elvis Presley /Brel, Jacques/ Gabriele Susanne Kerner [Nena ]
will
Presley, Elvis/Brel, Jacques/Kerner, Gabriele Susanne [Nena]

Action group

  1. action: regular expression (trim white spaces)
    Field: ARTIST
    Regular expression: ^\s+|\s+$
    Replace with: (nothing)

  2. action: regular expression (multiple white spaces replace to 1)
    Field: ARTIST
    Regular expression: \s{2,}
    Replace with: " " (whitout quotation marks)

  3. action: replace (delete white space after opening bracket)
    Field: ARTIST
    Original: "[ " (whitout quotation marks)
    Replace with: [

  4. action: replace (delete white space before closing bracket)
    Field: ARTIST
    Original: " ]" (whitout quotation marks)
    Replace with: ]

  5. action: split fields by separator (for the next actions)
    Field: ARTIST
    Separator: /

  6. action: regular expression (switches names without nickname)
    Field: ARTIST
    Regular expression: ^([^,[]+)\s([^,[]+)$
    Replace with: $2, $1

  7. action: regular expression (switches names with nickname)
    Field: ARTIST
    Regular expression: ^([^,[]+)\s([^,[]+)\s(\[.+\])$
    Replace with: $2, $1 $3

  8. action: merge duplicate fields (...back)
    Field: ARTIST
    Separator: /

2 Likes