Hi, I have a string variable which contains both text and numbers assigned to a string variable. I want to extract the numbers from the string using RegEx.
Example: If the text is “Text#$1234”, I want to extract “1234” alone
Thanks
Hi, I have a string variable which contains both text and numbers assigned to a string variable. I want to extract the numbers from the string using RegEx.
Example: If the text is “Text#$1234”, I want to extract “1234” alone
Thanks
Hi @JeevaSadha , can you try this?
\d+
This should extract the digits alone.
Thanks,
Aswin Sridhar
Hi @JeevaSadha
Try this:
Assign-> Input = "Text#$1234"
Assign-> Output= System.Text.RegularExpressions.Regex.Match(Input,"[0-9]+").Value.Trim()
Hope it helps
Hi, I’m able to assign it to a variable and extract digits alone. But, is there any other way we could extract all the digits like for example: if my text is qwerty1234uioo5678. I’d need the output to be “12345678”. However, I can iterate through matches but It would be helpful if I can get a regex to extract all numbers.
Thanks for your response
Hi
Input:-
Output:-
xaml File:-
Regex to get only numbers forum.zip (2.9 KB)
If this works for you, please mark this as a solution for others reference.
Thanks
Hi @JeevaSadha
Please check below:
String.Join("",System.Text.RegularExpressions.Regex.Matches(input.ToString,"(\d+)"))
Regards
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.