Fia
Fia

Reputation: 13

Regex. How to match just 2 digit numbers in a string

I want to get the 2 digit number and no number from more digit numbers. For example in string or word Hi3020want07see I just want the number 07, no digits from the 4 digit number (3020). Is there a pantern for this?

Upvotes: 1

Views: 195

Answers (1)

Toto
Toto

Reputation: 91415

Use:

(?<!\d)\d\d(?!\d)

This is matching 2 digits not preceded or followed by other digits.

Upvotes: 1

Related Questions