Extract dynamic text from string


I have to read texts from word doc and extract few texts which are dynamic by nature. I am able to achieve desired result by using substring and their positioning method but due to dynamic by nature the same method is not working in each case(if value change). I am attaching sample string output in which i need to extract text “SAP GRC Process Control” which is dynamic and below is the code from which i am able to get desired result.

Approver.Substring(Approver.IndexOf(“IT Service(IT/Non-IT)”)+24,23)

If possible please suggest any other alternatives to extract text between “IT Service(IT/Non-IT):” and “…9” from attached image.


we can try Regex:

And when we do make it more general we anchor on : and stop on digit followed by stop

For a first introduction to regex have a look here:

Just to confirm

That dots(…) in the quoted text and in the image will be the redundant value. And it seems like a OCR extraction that gives that non-alphabet characters.

Am I right on that?

If yes, once you get the text after using above regex mentioned by Peter, you may have to use regex to filter only alphabets.

@ppr I tried with regex but not getting relevant result

Please find the following attachment of input string with variable name “Approver”, output that i am getting and regex that i am using and suggest where i am wrong.

Regex that i am using:

Input String from which i am extracting value:

Output that i am getting:


WE cannot Use a toString on the Output of a Matches Activity Output.

Gibt a try on

Or use the the reges.match Methode directly

Could you please suggest how to use regex directly in Assign activity


@ppr Yes i tried it in same way but getting blank result

In below code Approver is input string with datatype string and i am assigning the output in variable xyz with datatype string.

System.Text.RegularExpressions.Regex.Match(Approver,"(?<=IT Service(IT/Non-IT):).*(?=9)").value.ToString

System.Text.RegularExpressions.Regex.Match(Approver,"(?<=IT Service(IT/Non-IT):).*(?=9)").value

System.Text.RegularExpressions.Regex.Match(Approver,"(?<=IT Service(IT/Non-IT):).*(?=9)").ToString

Kindly note that we had excaped the brackets etc. \( .... \)
ensure you have done the same

Cross checked during a debug paused by breakpoint within UiPath immediate panel:

Yes i have escaped the brackets etc. \( .... \) and still getting blank output while debugging.

I am using pattern:
System.Text.RegularExpressions.Regex.Match(service,"(?<=IT Service(IT/Non-IT): )(.*?)(?=9.)").Value

But you have noticed that on immediate panel it was passing the test?

just check on yourInputString for the regex that the pattern can be matched e.g. is maybe a space between ) and :

@ppr It is working fine now, there was issue with extra spaces. Thanx for you help.

Now output string looks like attached image and have to remove extra dots. I tried with below options but it didn’t work as expected.

First method:-
System.Text.RegularExpressions.Regex.Match(servicenew, “(^[A-Za-z]*$)” ).value

Seconf Method:-

Output string from which have to remove dots:


Hi @ppr,

Its working fine by using substring with Length method.

Thanx for you time.


feel free to do some testing and when it is done please close the topic by marking the solving post as solution.

In the case of you want trim/remove the ending dots you can do following:

  • send us the string with containing the dots
  • check with ASC(yourMatchResultString.Last()) for more details - it will retrun the ascii code of the dot char

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