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

activities

#1

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?


#2

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"


#3

Hi @andrzej.kniola,

Thank for your quick assistance.

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


#4

Check here:

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


#5

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)


#6

You can do like this:

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(your_str_var)


#7

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


#8

Hey @sterner

Try this: test.xaml (4.9 KB)

Regards…!!
Aksh


#9

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.


#10

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());