Extracting 4 digits

Can somebody help me extract all exact 4 digits substrings from random string.

Ex_“adfsdf4647snsdčlnv 4895dv 458 1 45687”
Resoult : 4647 and 4895

Can you check?
grafik

with some refinement on borders
grafik

1 Like

HI @tomaz

Checkout this expression

System.Text.RegularExpressions.Regex.Match(System.Text.RegularExpressions.Regex.Replace(InputString,"\d{5,}","").Tostring,"\d{4}").ToString

Regards
Sudharsan

Regards
Sudharsan

hI, how can I get all Resoults into variable?

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

Assign Activity:
strPattern = "(?<=\D|^)\d{4}(?=\D|$)"

Assign Activity
arrResult | String Array - String() =

System.Text.RegularExpressions.Regex.Matches(YourStringVar, strPattern).Cast(Of Match).Select(Function (x) x.Value).toArray

Or work with the Matches Activity

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