Regular Expression to extract 7 digit word

Hi All,

I want to extract a 7 digit word from a string after a particular string. Can anyone help to write regular expression?

Sample I/P Text : Order. Number 9123145
Required Output : 9123145

Hi,

Hope the following helps you.

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

OR

System.Text.RegularExpressions.Regex.Match(yourString,"\b\d{7}\b").Value

Regards,

Hello @rifnanahas Try this
Vat1=" Order. Number 9123145"
“\d+”

System.Text.RegularExpression.Regex.Match(Var1,"\d+").tostring.trim

Hi @rifnanahas

How about this expression? Alternative solution

System.Text.RegularExpressions.Regex.Match(InputString,"(?<=Order.\sNumber\s)(\d+)").Value

image

Regards
Gokul

Hey! Welcome to community!

Try this:

System.Text.RegularExpressions.RegEx.Match(strInputVariable,"\d{7}").ToString

Reference: