How to get sub-string from a string

Hi,

I have the following string, how to extract the substring out of it?

InputString::

Action Created.
(Confirmation # = 492854374)

No Further action os needed.

OutputString

492854374

What is the best way to extract that output? It’s always numeric.

grafik

1 Like

number keeps changing and I want only the number.

Hi @Krithi1 ,

You can achieve that using the following regex pattern - \(\Confirmation\s*\#\s*\=\s*(.*?)\)

It will extract numbers in the text structure you have provided.

strOutput = System.Text.RegularExpressions.Regex.Match(strInput, "\(\Confirmation\s*\#\s*\=\s*(.*?)\)").Groups(1).Value

Regards,
Ranjith Udayakumar

this regex is looking for digits and so it will handle different digits in different length. Or did you mean something different?

Hello Kirthi,

If your input string is just that, you can use below regular expression to extract numeric values from the string. find below image for reference.

You can use the same by using Assign Activity

  1. Use Assign Activity like this, vConfirmationNumber = System.Text.RegularExpresssion.Regex.Match(InputString,“\d+”).ToString

The image shows a regular expression  being tested against a string that includes a confirmation number , with the number correctly highlighted as a match. (Captioned by AI)

@Pradeep_Shiv
I tried this and it gives only the first char from the entire number.

just share with us the details on what was modelled. Feel free to do the prototyping directly within the immediate panel:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Can you share the screenshot of the input and output?

@Pradeep_Shiv

Please ignore my earlier comment. It’s working. It’s just that I did something wrong on my end.

1 Like

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