Use the substring indexof method

I have a text “Casid (Our Id) : 23142341574-05 (Status)” and I’m using strLoanStatus.Substring(strLoanStatus.IndexOf(“(”) + 1) to try and retrieve the value (Status) within the string but it always returns “Our Id) : 23142341574-05 (Status)” what would be the fix for this.

If there’s a better way to do this please advise.

Hi @duaine.b,

You can use regex with following expression:

System.Text.RegularExpressions.Regex.Matches(“23142341574-05 (Status)”,“(\w+\)”)(0).Value

Hope it helps.


Hi @duaine.b

Can you try using the following RegEx to extract the data:


System.Text.RegularExpressions.Regex.Match(yourText, “(([^)]+))$”).ToString



Hope this helps,
Best Regards.

1 Like

Hi @duaine.b ,

Check this below code,

If your input string is of single line:-
requiredStr = System.Text.RegularExpressions.Regex.Match("Your Input String","(?<=\()[A-z]+(?=\))").Value

If your input string is of multi-line:-
requiredStr = System.Text.RegularExpressions.Regex.Match("Your Input String","(?<=\()[A-z]+(?=\))", System.Text.RegularExpressions.RegexOptions.Multiline).Value


Hope this might help you :star2:

1 Like

Hi @duaine.b

To retrieve the value of “Status” from the text “Casid (Our Id) : 23142341574-05 (Status)” using UiPath, you can modify your substring method to include an additional argument for the length of the substring you want to extract.

Here’s an example of how you can extract the “Status” value from the given text using Substring method in UiPath:

  1. Assign the given text to a variable, for example, strLoanStatus.
  2. Use the Substring method to extract the “Status” value from the text. Instead of using strLoanStatus.Substring(strLoanStatus.IndexOf("(") + 1), use the following code to extract the “Status” value:

strLoanStatus.Substring(strLoanStatus.IndexOf(“(”) + 1, strLoanStatus.IndexOf(“)”) - strLoanStatus.IndexOf(“(”) - 1)

1 Like

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