I have searched for similar questions, and even though I found several answers, none seams to work. I have a list of strings
Z189
I142
M395
L210
V467
M203
Q277
Q461
Y440
S250
M162
Q96
22Q
W148
Q72
T22T
22TWE22
12E34
and I need a regex to find only strings holding only 2 digits (not more or less). So in this case:
Q96, 22Q, Q72, T22T
my failed attempts include:
\D\d{2}\D
(?<!\d)\d{2}(?!\d)
You could use ^\D*(\d)\D*(\d)\D*$
\D* makes sure anything before your first digit isn't another digit.
(\d) captures your first digit.
\D* makes sure there is no other digits between your two digits.
(\d) captures your second digit.
\D* makes sure anything after your second digit isn't another digit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With