cancel
Showing results for 
Search instead for 
Did you mean: 

Converting to Upper/Lower case

Sophie_Katherin
Level 3

Hi all,

Does anyone know a simple way to convert a text data item so that every letter after a space is a capital letter and the rest is lowercase? The data item could be made up of 1/2/3/4 etc words and could either already be in this format or could be all upper or all lower case.

Thanks.



------------------------------
Sophie Katherine Smith
HR Systems, Data and Quality Assurance Manager
Arup
Europe/London
------------------------------
5 REPLIES 5

DaveMorris
Level 14
My suggestion may be very inefficient if the data item has a lot of words in it. So I'm suggesting a possible solution below based on your saying 1 to 4 words or so.

  1. Pass the Text data item into the action 'Split Text' from the object 'Utility - Strings'.
    • Input for Text to Split: [Text Data Item]
    • Input for Split Char: " "
    • Input for Collection Field Name: "Item Value"
    • Output for Split Values: collection named [Split Values]
  2. Next do a loop using Loop Stages on the collection [Split Values]
    • Loop Start
    • Calc stage with expression: Upper(Left(Trim([Split Values.Item Value]),1)) & Right([Split Values.Item Value],Len([Split Values.Item Value])-1)
    • Above Calc stage should store in [Split Values.Item Value]
    • Loop End
  3. Then pass the collection Split Values into the action 'Join Text' in the object 'Utility - Strings'.
    • Input for Values: [Split Values]
    • Input for Join Character: " "
    • Input for Trim Values: False
    • Output for Joined Text: [Text Data Item]


------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------
Dave Morris 3Ci at Southern Company Atlanta, GA

Awesome, thanks Dave I will give it a go. The data items are going to be first name(s), first line of address etc so there shouldn't in theory be much more than 4/5 words!

------------------------------
Sophie Katherine Smith
HR Systems, Data and Quality Assurance Manager
Arup
Europe/London
------------------------------

Hi Sophie, 

If your address text contains numbers, (1234 LIBERTY STREET NW for example) you may have to add some additional logic to test if the text contains numbers in order to avoid a system exception because if you try to convert text using the ToUpper() or ToLower()  functions for data items containing numbers, Blue Prism will trigger a casting exception. 

Dave's suggestion looks good, just be aware of additional handling logic that may have to be built around that process to catch special character situations when you are formatting the text.

Hope that helps.

------------------------------
Jorge Barajas
Senior Product Consultant
Blue Prism, North America
Jorge Barajas Blue Prism Senior Product Consultant Austin, Texas

Thanks Jorge, good point!

------------------------------
Sophie Katherine Smith
HR Systems, Data and Quality Assurance Manager
Arup
Europe/London
------------------------------

NicholasZejdlik
Level 9
If you're using a code stage this can be done via regex:

Result = System.Text.RegularExpressions.Regex.Replace(<your_string_here>, "(?<= )\w", Function(m) m.Value.ToUpper())


I'd personally go with Dave's solution as I try to avoid code stages for one-off pieces and there's not much reuse value with this solution.



------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------