Regex for exact string match

Hi guys! Hope you can help me out with something. I have an array of strings and i need to pick only the strings based on this filters: begins with 1 or 2, string is made of numbers only, string length is 10.
Example:
1923421423 this one should be picked
2134567890 this one should be picked
2123421 this one shouldn’t be picked
2134567543212123234 this one shouldn’t be picked.
21312412asdasd2341 this one shouldn’t be picked.

I’ve tried this Regex but it picks also strings with length bigger than 10: \d{10}|^((1)|(2))

Hi @RaduNRV

Please try this syntax

[1-2]\d{9}[^\d\w]

image

Also try this:

\b^[1|2]\d{9}\b

Capture

1 Like

Not working. I don’t know why but @SenzoD works fine

Many thanks. Works great.

1 Like

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