How to extract specific number from string

Hi Team,
I have a task wer i have to extract a specific number from string so below is the exacmple

I want to extract 8 from below string

H + 8

please help me to achieve this

= 8

@bhanu.priya2

If it is always after 8 and in same format then

requirednumber = Str.Split("+"c).Last.Trim

Cheers

number is not constant, it wont be always 8

Will the number always be at the end of the string, and can be greater than 9?

@bhanu.priya2

As I said number need not be constant but it should be always after + and number should be the last one present after +

Cheers

Hi @bhanu.priya2

Try this:

Input = "H + 8"

Output = System.Text.RegularExpressions.Regex.Match(Input, "(?<=\+\s*)\d+").Value.Trim()

The above syntax will extract what ever may be the number present after +

Regards

Hi @bhanu.priya2

Try this

\d+

System.Text.RegularExpressions.Regex.Match(Input, "\d+").Value

Regards,

Hello

To learn more about Regex take a look here :slight_smile:

Cheers

Steve