Extract exectley 4 consecutive numbers from a random multiline string

hello, can someone please tell me how I can extract exectley 4 consecutive numbers from a random multiline string.
ex:

“asvf47586adsv
fafd45
2000 cdewCr”

for this example resoult should be only “2000”

Hi,

How about the following?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=^|\D)\d{4}(?=\D|$)").Value

Regards,

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