[Solved] Regex for these strings [closed]


You can use:

[1-7]|9|8[abcd]

Depending on whether you want the whole string to match, so that nothing else follows or precedes the match, you may need to add anchors:

^([1-7]|9|8[abcd])$

Or, alternatively, if you just want to match digits that are not followed by a letter (a, b, c, d) except when it is 8 (where it is required), then:

([1-7]|9)(?![abcd])|8[abcd]

solved Regex for these strings [closed]