How to manipulate the string CITY OF ANGELS into City of Angels?

Hi, I have a variable that receive strings on upper case I’m converting it to Proper case using this:

StrConv( myVariable,VbStrConv.ProperCase)
My issue is that leaves me with
CITY OF ANGELS = City Of Angels. And I need: City of Angels

So for example, I can receive this names on this variable:

NEW YORK - New York
CITY OF ANGELS - City of Angels
SAINT JOHN OF FLOWERS - Saint John of Flowers

How can I do it?

@Alamyr_Junior

Check as below

image

Mark as solution if this helps

Thanks

1 Like

Hi @Srini84,

“Of” needs to be all lower…

Can you explain the rules? Maybe to create dictionary with exceptions…

It’s always when it have a preposition in portuguese, for that case it can be: “Da”,“Do”,“Das”,“Dos”,“De”.

How can I do using a dictionaty with exceptions?

It won’t be very simple. First you should convert the string to title case as mentioned above. Then, use that comma separated list of strings as part of a regex replace. Here is the code on how to do it (assuming YourText is the input string variable that is already converted to title case)

Regex.Replace(YourText,"\b(Da|Do|Das|Dos|De)\b",function (x) x.value().ToLower())

EDIT: I’d recommend storing that list of strings in your config or as an orchestrator asset so it is easy to add/remove words as necessary

EDIT2: See attached showing it in action with the “SAINT JOHN OF FLOWERS” example: delete.xaml (5.7 KB)

1 Like

Thanks, Dave! Nice solution!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.