RegEx Problems | need to check number range

I would like a regex that matches a string that ends with digits between the range 0-17

. For example test_1.png

or test_08.png

.

I tried the following:

(.*)_(([0-1]\d|[0-7])).png

but it skips lines with 8

or 9

, i.e. test_9.png

... My string can contain the filename with 0

or without 0

, i.e. test_07.png

or test_7.png

. How do I change my RegEx so that no lines are skipped?

+3


source to share


1 answer


You need to change the regex to highlight the part with the first digit 1

:

(.*)_(0?\d|1[0-7])\.png

      



Demo version

+8


source







All Articles