RegEx For Extracting Middle Intial From String

HELP

I need a RegEx For Extracting Middle Intial From String

Ex. John H Moriarty (Format is Fixed)

o/p should be = H

1 Like

Hi

Welcome to UiPath forum

Use a assign activity like this
I assume u have saved the input string in variable named Strinput

stroutput = System.Text.RegularExpressions.Regex.Match(Strinput.ToString, “\b\w\b”).Value.ToString

Hope this helps

Cheers @Ankit2

Assign: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled

This Error is coming

Hi @Ankit2

Use this Regex expression

Input= " John H Moriarty"
Output= System.Text.RegularExpressions.Regex.Match(Input,"\b[A-Z]\b").Value

Or

Input= " John H Moriarty"
Output= Input.Split(" ")(1)

Hope it helps!!

1st Solution Worked

Thanku so much

1 Like

@Ankit2

If you find the solution for your query please mark it as solution to close the loop.

Happy Automation

Regards

1 Like

Try now @Ankit2

Hope it’s clarified

1 Like

yes thanku for helping out

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.