Extract only digit from Text

Hello Team,

We have a text present in below format

Example:

Result List : 1 document found

Value to extract : 1

image

Follow this:
\d+

You can try this

[0-9]{1}

image

@NISHITHA

you can try this way also

System.Text.RegularExpressions.Regex.Match(str,"[0-9]{1}").Value

@NISHITHA

Thanks @tazunnisa.badavide , @Praveen_Mudhiraj for the quick responses

Just one question @Praveen_Mudhiraj will it work even if there are 2 digit or 3 digit value ?

You can try this then it will match digits if 1 or 2 or 3 more

@NISHITHA

@NISHITHA

try like this

str = “yourText”

System.Text.RegularExpressions.Regex.Match(str,"[0-9]{1,}").Value

out put : -

HI @NISHITHA

@NISHITHA the regexx above will even word if there are more than one digit

Hi @NISHITHA

Input= "1 document found"
Output= System.Text.RegularExpressions.Regex.Match(Input,"\d+").Value

The above regex will extract if there are multiple numbers present at the same place.

Hope it helps!!

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