Jump to content

Make the words inside the brackets to title case


Marco Cruz

Recommended Posts

I have got a rxreplace script here and this changes 'test and test (tat)' to 'Test and Test (tat)', but i also want the brackets inside to be title case, such as 'Test and Test (Tat)'. Can you please help me how to make the word inside the bracket to be case sensitive

RXReplace(

RXReplace(Lower('test and test (tat)'),"(^[a-z]| [a-z]|(^[a-z]))","\U$1","g"),

"(!^)(A|An|The|This|And|But|Or|For|Nor|At|On|In|For|Since) ","\L$1 ","g")

Link to comment
Share on other sites

By slightly reworking the first part of your expression it seems to do what you wanted, at least for the example provided:

RXReplace(RXReplace(Lower('test and test (tat)'),"\b([a-z])","\U$1","g"),"(!^)(A|An|The|This|And|But|Or|For|Nor|At|On|In|For|Since) ","\L$1 ","g")

I put a word boundary \b there so it should match any transition from a non-word character to a word character. Seems ok also for matching the start.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...