How to get all the numbers seperatly from string

Hi All,

I am trying to get all the numbers set separately from below type of strings.

String:- Check for your number provided 67654876 and 8765 4456. Also check if this is 78/96 54/3 -56 correct.

Expected result:- 1st Number = 67654876 , 2nd Number = 87654456, 3rd number =789654356

I have already checked on forum for this type of solution but not get. U tried for System.Text.RegularExpressions.Regex.Replace(a,"\D","") and received output as 6765487687654456789654356. This is not as per my requirement.

I am looking for three separate numbers in a variable.

Please help me to provide a work around on this.

Thanks for the help in advance.

Thanks

1 Like

Hi,

can you give us more information on it?

You can split the whole String as a List String Datatype and check your conditions.

How does the String look like @upendermahato?

e.g String = 123445345-2345 67876-2222233

If the String looks like this you can split it with the “-” seperator and assign it to variable if your condition matches

ENG Split Trim Substring Left Right Replace Remove.xlsx (26.3 KB)

Maybe you can also look up on this excel sheet to find your solution.

This was also shared from a UiPath Forum Member

HI

welcome to uipath community

here you go
hope its resolved
regex11.zip (9.6 KB)

Cheers @upendermahato

Hi,

I suppose you need to get them with the following steps.

  1. Use Matches activity with the following settings.
    Input: your string data
    Pattern: "\d[0-9/\- ]*"
    Result: res ( IEnumerable type)

  2. Use Assign activity as follows:
    arrString = res.Select(function(x) System.Text.RegularExpressions.Regex.Replace(x.Value,"[ \-/]","")).toArray

Finally you can get your 3 value in arrString.

Regards,

Hi Yoichi,
Thanks for looking into this and trying to help me out.
I have tried as suggest by you but not get the expected result.
Attaching my code file. Please check and help me to correct if I have done something wrong.
Thanks for the help in advance.Main.xaml (12.1 KB)

Hi,
Thanks for looking into this and trying for help me.
Place from where I am trying to pull the data is a free text option and user will mentioned the number in any format and way.
Text given by me and the number is correct. Please don’t look that number as cell number or anything else.
I just need those three numbers in a array string to perform sum further check basis on those number one by one.
I hope I have explained you my requirement.

Thanks for your help in advance.

Hi Palaniya,
Thanks for looking into this and trying to help me.
I have download the file you have given.
But when opened it got an error " Could not find member ‘CurrentIndex’ in type ‘http://schemas.uipath.com/workflow/activities:ForEach(Match)’. Row: 73, Column: 45" while opening.
Please check and share the file again. I am using 2016 version of Ui-Path.
Thanks

Hi,

You can see the value of arrString using For Each activity.

For Each

  • Values: arrString
  • TypeArgument : String

Then you can see the content as item.
Please use Messagebox (item) in the For Each.

Or you can directly access each element as the following.
arrString(0)
arrString(1)
arrString(2)

Regards,

It’s got worked. Thanks a lot.

1 Like

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