I want to match strings that have less or equal to 2 digits, but not more than 2 digits. If the digits are not consecutive, they could be more than 2 digits in total, but each consecutive digits should be at most 2 letters.
So, I want to match strings like
42 ABC92 05XYZ ABC82XYZ ()%^.90 XYZ AB 47.jpg 3 83abc29 9abw88ak ak8+
but not
426 ABC9242 05697XYZ ABC8232XYZ ()%^.9068 XYZ AB 479.jpg 483 a8
The letter before or after the digits can be not only alphabets, but also any characters that are not digit (No letters before or after the digits can be possible, and such strings should be matched, too).
.*[[:digit:]]{1,2}.* matches strings that have more than 2 digits, too. This is not what I want.
How can I do this?
ABC2dsd2should it match ?