Using "Whole Word" in an Action

Hi,

I've set up some capitalization Replace rules using the 'whole word' option. When that word is bracketed by other than spaces, the action doesn't get executed. For example, my rule replaces the word uk to UK. But the string '(uk uk uk)' ends up as '(Uk UK Uk)'. Is this the expected result? Do I need to change all replaces to regular expressions in order to get the right result? I would not expect symbols to be part of words.

Terry

Terry, you did not say what your capitalization rules look like and which Mp3tag features you have used to reach your goal. Please elaborate your situation.

This works for me ...
from:
(uk uk uk)
to:
(UK UK UK)

Action #1
Actiontype 1: Case conversion
Field: TJWHALE
Case conversion: UPPER CASE
Word begins after:

.. or this ...

Action #1
Actiontype 5: Format tag field
Field: TJWHALE
Formatstring: $replace(%TJWHALE%,'÷uk÷','÷UK÷','(uk÷','(UK÷','÷uk)','÷UK)')
Note: Replace each special ÷ character with one space character.

... or this ...

Action #1
Actiontype 4: Replace with regular expression
Field: TJWHALE
Regular expression: (?<=[(÷])uk[÷)]
Replace matches with: \U$0

[_] Case sensitive comparison

Note: Replace each special ÷ character with one space character.

DD.20091128.1130.CET

DetlevD,

I am currently using
Action:REPLACE
Field:_FILENAME
Original: uk
Replace with: UK
and checking the 'only as a word' box.

Last night I was thinking maybe something like this in a regular expression replace might be better:

Replace: ([^a-z]|^)(uk|mtv|nyc|usa)([^a-z]|$)
With: $1$upper($2)$3
[your \U$0 gets the same results. Does it mean uppercase the entire string?]

That way I can put all things to uppercase in one place. Well, I just tried this, and it kind of works, but not totally. I'm using a test string Of:

uk (usa nyc mtv) ( uk) nyc usa (uk uk uk) uk

The result is:

UK (USA nyc MTV) ( UK) NYC usa (UK uk UK) UK

Any thoughts on why some strings bracketed by spaces don't get uppercased?

Thanks for your help.

(update: I see why it doesn't work, the leading space for the failures is used up by the previous match. Is there a fix for this? A symbol perhaps that works like ^ but for the start of the next match-search?)

These expressions work for me ...

$replace($regexp($replace(%TJWHALE%,' ',' '), '(^|\(| )(uk|mtv|nyc|usa)( |\)|$)','\U$0'),' ',' ') $regexp($regexp(' '%TJWHALE%' ','(?<=[\( ])(uk|mtv|nyc|usa)[ \)]','\U$0'),' (.+) ','$1') $regexp(%TJWHALE%,'(^|(?<=[\( ]))(uk|mtv|nyc|usa)([ \)]|$)','\U$0') $trim($replace($replace($replace(' '%TJWHALE%' ', ' ',' ','(','( ',')',' )'),' uk ',' UK ',' mtv ',' MTV ',' nyc ',' NYC ',' usa ',' USA '), '( ','(',' )',')',' ',' '))
From:
"xnyc uk (usa nyc mtv) ( uk) nyc usa (uk uk uk) uk gnuk uk"
To:
"xnyc UK (USA NYC MTV) ( UK) NYC USA (UK UK UK) UK gnuk UK"

DD.20091129.0651.CET
Edit. DD.20091130.0819.CET
Edit. DD.20140128.1023.CET

Thanks, that works fine.

I don't want to beat this to death, but I'm still trying to figure out the expected behavior of the 'whole word' check box in the Replace action. Is it a deficiency or desired result that a string of characters is considered a word only if it's bracketed by spaces, beginning of string, or end of string? If expected, it would seem to be of limited usefulness.