Removing text and leaving only numbers in string

I have a variable which gets text.

The text will be: “Your transaction number 123456789 has been submitted”

How can I make the output display only the numbers?

Output: 123456789

Hi @dvn

use regex expressions

\d{9}

Thanks
Ashwin S

2 Likes

@dvn Try using this Expression in a Message Box :
System.Text.RegularExpressions.Regex.Matches(“Your transaction number 123456789 has been submitted”,"\d+")(0)

1 Like

Use this regex to solve
System.Text.RegularExpressions.Regex.Matches(inputstring,"([0-9]+)")

1 Like

Try the regex with Replace all the text except numbers .

Hi @dvn,

If you want to keep all the digits present in a string and remove all the other characters then, please try with the below -

System.Text.RegularExpressions.Regex.Match(YourString, “[0-9]+”).ToString.Trim

Thanks & Regards,
Apurba

1 Like

@dvn, Got solution ah? if you got Solution means close/Mark the solution - corresponding replied for you

Thanks and Regards,
Vivek

1 Like