<REGEX> Extract 2 numbers from a single string

how to extract 2 numbers from below mentioned string?
Input:
12345666666666789302
8676866786867686766252536123F

Ideal output:
1st number: Ending with 302
2nd number: ending with 123F

Hi @anjasing

Check the below regular expressions,

\d+(302)

image

\d+(123F)

image

Check the below workflow for better understanding,

- Assign -> Input = "12345666666666789302
                     8676866786867686766252536123F"
- Assign -> Number1 = System.Text.RegularExpressions.Regex.Match(Input.toString,"\d+(302)").Value

- Assign -> Number2 = System.Text.RegularExpressions.Regex.Match(Input.toString,"\d+(123F)").Value

Hope it helps!!

1 Like

Hey @anjasing
you can try use this:
System.Text.RegularExpressions.Regex.Match(yourInputStringVariable, "\d*302\b").Value

System.Text.RegularExpressions.Regex.Match(yourSecondInputStringVariable, "\d*123F\b").Value

1 Like

@anjasing


.*(302|123F)

image

1 Like

Hi @anjasing

You can use this Regex phrase below for your examples or for any other strings which you want to extract the last 3 numbers and the last letter in the string.

(\d{3})\D*$

image

I hope this helps you, happy automation :blush:

1 Like

Thank you so much :slight_smile:

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