How to add white space in a name?

I want to convert a name in the field artists by using regular expressions

The name is in this format:
a.b.name, c.d.e.name

i need it to be as:
A. B. Name, C. D. E. Name

i am not sure how to search the forum for such an example, so i am sorry if this is already answered. Thanks for the help in advance.

You don't need a regular expresion to insert the white space.
Just create an action group with 2 actions.
First action is a simple replace action.

Field: ARTIST
Original: .
Replace with: .

Note: There is a white space behind the dot in "Replace with" that you don't see here.

After inserting the white space you can change to capital letters:

Action Format Value:
Field: ARTIST
Format String: $caps(%artist%)

I already tried this and it doesn't work properly. It adds an extra space for correctly formatted names. So A._B._Name becomes A.__B.__Name (the underscore represents space)

Action Format Value:
Field: ARTIST

  1. Add exactly one space after (.) not followed by space. Convert to Mixed Case.
    Format String: $caps($regexp(%artist%,'(.)(?!\s)','$1 '))
  2. Add exactly one space after (.) not followed by space and remove additional trailing spaces. Convert to Mixed Case.
    Format String: $caps($regexp(%artist%,'(.)((?!\s)|\s+)','$1 '))

Just out of curiosity: why the hassle with the regular expression? To me it looks just like an ordinary "Replace" action: you replace one constant string (the dot) with another constant string (the dot plus blank).
Afterwards you have to tidy it is up, again with a normal replace: replace two blanks with just one.
And then you can do the $caps stuff ...
So it should be possible to do
$caps($replace(%artist%,'.','. ',' ',' '))

Regular expression allows user to execute several times the action.
With simple replace he may end with multiple trailing spaces after the dot when executing the action several times.
On top of that $replace(,' ',' ') does not work for 2 or more spaces in a row. They will stay at least two spaces.

Awesome... Thanks Victor, much appreciated.

May be someone wants to change the title of this thread to better represent the problem? it will help with new searches.

I just tested that with a couple of files and it removed the double spaces every time with just one.
BUT: if you copy&paste the expression from this forum then it does not work as apparently the forum editor removes double blanks from pain text...
So in that respect, I still think that the plain replace is just as nice as toghether with the double space remover it leads to just the same result.

I admit it works the same way for majority of cases for trailing spaces of dot.
There are two differences.

  1. Regexp will touch only trailing spaces of dots (.). :wink: A._B._Group____Name would stay untouched from regexp while $replace would involve all spaces (A._B._Group__Name). Still multiple spaces will stay.
  2. $replace(%artist%,'.','. ',' ',' ') does not work as expected when applied to A.___B.___Group_Name unlike $regexp(%artist%,'(\.)((?!\s)|\s+)','$1 '). Result is A.__B.__Group_Name vs A._B._Group_Name.
In general $regexp(value,'\s+','\s') replaces multiple spaces in a row with exactly one space. $replace('A__B','__','_') works well but not $replace('A____B','__','_'). Maybe this behavior is a bug??? Regexp gives more freedom but it is more complicated. :slight_smile:

Totally aside from the expression problem I also see a semantic problem.
I know of band names like
A.A.B.B. (Above Average Black Band)
A.I.D.A.
A.K.-S.W.I.F.T.
A.M.C & Mattix & Futile
Alex M.O.R.P.H. & Rank 1
B.B. King
Bcee & S.P.Y.
C.C.S.
D.I.T.C.
D.A.F. (Deutsch Amerikanische Freundschaft)
D.Ö.F (Deutsch-Österreichisches Feingefühl)
DJ R.O.C.K.
DJ S.P.U.D.
I.Q.
M.F.S.B.

and may more. These names apparently have to be written like this without the blanks after the dots .... so a lot of filtering will be necessary. Or undoing the changes ....