Extract text after number of special characters

Hi everyone

I have some string as below… i need to extract four number after “…XXX”

hfhughXXXXX1234
gbnfkXXXXXXXXX2341
jvnvXXXXXXX1111

The result : 1234, 2341, 1111

How to define number of “X” more than 3 character then will extract four number after it.

Thanks you!

Hi,

We can get them using Matches activity with the following pattern

"(?<=xxx)\d{4}"

If your target number exists at the end of the line, the following also works.

Pattern : "\d{4}$"
RegexOptions : Multiline

Regards,

1 Like

I have used this command but it still do some step : left(System.Text.RegularExpressions.Regex.Match(MyString.ToString,”(XXX).*(\d)”).ToString.Replace(“X”,“”).Trim,4)

How to do regex it only with one step

Thanks you bro!

1 Like

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