How to convert the string into Proper Case/Title Case?

In Visual Basic platform we have vbProper, ToTitle() function to convert the string into Proper Case/Title Case.

How to perform the same in UiPath?

UiPath uses VB.Net, so what you can do there is here as well:
requires System.Globalization namespace to be imported
CultureInfo.CurrentCulture.TextInfo.ToTitleCase("aaa bbb") //returns "Aaa Bbb"

13 Likes

Hi @andrzej.kniola,

Thank for your quick assistance.

Please let me know, how to import the System.Globalization namespace in UiPath.

1 Like

Check here:

(note - Imports panel is next to Variables and Arguments tabs, by default below the Designer canvas)

2 Likes

Hi @andrzej.kniola. I tried your example and it works fine but now I would like to use a string variable instead of the “aaa bbb” text. I’m sure it’s very simple but I’m not getting it. Thanks. CultureInfo.CurrentCulture.TextInfo.ToTitleCase(StringVariable)

You can do like this:

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(your_str_var)

Thanks @aksh1yadav. I tried that but couldn’t get it to work. It left my string as UPPERCASE. Any other ideas?

Hey @sterner

Try this: test.xaml (4.9 KB)

Regards…!!
Aksh

1 Like

Thanks for that @aksh1yadav. I worked out the issue. The ‘ToTitleCase’ method doesn’t work with upper case. So I used ‘ToLower’ to first make lower and then ‘ToTitleCase’. Problem solved and many many thanks.

4 Likes

Yeah

From the MSDN:

Generally, title casing converts the first character of a word to
uppercase and the rest of the characters to lowercase. However, this
method does not currently provide proper casing to convert a word that
is entirely uppercase, such as an acronym.

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(your_str_var.ToLower());

3 Likes