cancel
Showing results for 
Search instead for 
Did you mean: 

Checking if the first letter of a data item is Uppercase

ShaluKhandelwal
Level 3
I want to check if the first letter of words in a data item is uppercase and the rest set are lowercase. 

------------------------------
Shalu Khandelwal
------------------------------
1 BEST ANSWER

Helpful Answers

EVIPUTI
MVP
Adding to what @Ved Sengupta said :

Use Utility-Strings VBO, use Action : Test Regex Match
Input
Pattern: "^([A-Z][a-z]+\s*)+$"​

------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification and Optimization Designer(Solutions Architect)
Fidelity International
------------------------------
------------------------------
------------------------------ Vipul Tiwari Senior Process Simplification Developer Amazon ------------------------------

View answer in original post

7 REPLIES 7

VedSengupta
Level 6
Hello Shalu,
Please try using Regex for this.
Give a pattern to check if first letter is Uppercase and rest are Lowercase.

------------------------------
------------------------------
Best Regards,
Ved Sengupta
RPA Developer
Deloitte India (Offices of the US)
Bangalore | INDIA
------------------------------
------------------------------
------------------------------ Best Regards, Ved Sengupta RPA Developer Deloitte India (Offices of the US) Bangalore | INDIA *If you find this post helpful mark it as best answer* ------------------------------

EVIPUTI
MVP
Adding to what @Ved Sengupta said :

Use Utility-Strings VBO, use Action : Test Regex Match
Input
Pattern: "^([A-Z][a-z]+\s*)+$"​

------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification and Optimization Designer(Solutions Architect)
Fidelity International
------------------------------
------------------------------
------------------------------ Vipul Tiwari Senior Process Simplification Developer Amazon ------------------------------

@Ved Sengupta Which utility should I use for Regex and if you can also share the Regex for the same ?​

------------------------------
Shalu Khandelwal
------------------------------

david.l.morris
Level 15
It looks like you've already gotten the answer you needed, and I think that Regex is the right way to go. But, just because I couldn't help myself, I wanted to see what this would require if even possible in a Blue Prism expression.

Here's what I came up with. If you needed to determine simply true or false for whether the text is formatted with the first letter as uppercase and the rest lowercase, then I think this would work in a Decision Stage. The idea is to convert the first letter to uppercase and compare it to the original, and then convert the rest of the text to lowercase and compare to the original. If no characters were changed, then we know it's in the right format:
Upper(Left([text],1))=Left([text],1) AND Lower(Right([text],Len([text])-1))=Right([text],Len([text])-1)
or
Upper(Left([text],1)) & Lower(Right([text],Len([text])-1))=Left([text],1) & Right([text],Len([text])-1)

And then if you wanted to just not even worry about it and always convert the text to the desired format, then you can use this in a Calculation Stage:
Upper(Left([text],1)) & Lower(Right([text],Len([text])-1))

I believe that both of these will work, regardless of the text that comes through and whether or not it contains numbers.

It'd be nice if we could do simple stuff like this directly in an expression using regex or whatever else, but it is possible currently even if not very nice looking. 😃



------------------------------
Dave Morris
Cano Ai
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company

Thanks for sharing mate @Dave Morris it was helpful 🥂​

------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification and Optimization Designer(Solutions Architect)
Fidelity International
------------------------------
------------------------------
------------------------------ Vipul Tiwari Senior Process Simplification Developer Amazon ------------------------------

Hello Dave,
One a different not with addition to your assumptions to the solution.
Why are we checking for the entire string ?

If the target is to check if the first letter is upper case and rest are lower case and we are expecting a Boolean output I think just checking if the first letter is upper case followed by checking if any other Upper case exists would do right?​

I am not sure if we can try with ASCII values!

If so then I think that comparison would do.

Just suggesting as I am myself not very adapted to Regex yet. So a workaround maybe.



------------------------------
------------------------------
Best Regards,
Ved Sengupta
RPA Developer
Deloitte India (Offices of the US)
Bangalore | INDIA
------------------------------
------------------------------
------------------------------ Best Regards, Ved Sengupta RPA Developer Deloitte India (Offices of the US) Bangalore | INDIA *If you find this post helpful mark it as best answer* ------------------------------

I thought about using ASCII values, but I cannot think of a way to implement that inside of a Blue Prism expression using only a single stage. It could be done using a loop, but doing anything in a loop in Blue Prism will cause it to run slower at runtime, so I wanted to do it in a single stage. The expressions in Blue Prism are designed to not really be possible to do really complex things. The most limiting factor is that If statements aren't easily achievable inside of an expression. That's why I went with using Upper() and Lower(). And I imagine the rest of the string could be converted to to Uppercase to do the check as well, but I used Upper() for the first letter and Lower() for the rest of the letters to make it (1) more readable and (2) match the last example I gave which actually does the conversion.


------------------------------
Dave Morris
Cano Ai
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company