Is there any regex (!) which can test if a string contains 3 digits ( never-mind the order) ?
(at least 3 digits. also I be happy to see the exact 3 solution.( if you’re kind ))
example :
abk2d5k6 //3 digits
abk25k6d //same here //3 digits
my fail tries :
.+?(?=\d){3}
Thanks.
(only regex solutions please , for learning purpose.).
Well, for the learning purpose, I suggest to read through this very comprehensive tutorial.
Otherwise, the JavaScript regex would probably look something like this:
if you want to make sure that there are at least three digits:
Or if you want to make sure that there are exactly three digits:
\Dis any non-digit character.*allows 0 or more of those.\dis any digit character.{3}repeats the subpattern 3 times. And^and$mark the start and end of the string, respectively.