Here is a valid string that always start with fixed string SOME_START_FORMAT_
then end with one or more digits. So valid strings are
SOME_START_FORMAT_1234
SOME_START_FORMAT_12
Invalid strings are
SOME_INVALID_FORMAT_1234
SOME_START_FORMAT_
SOME_START_FORMAT_1234_
SOME_START_FORMAT_1234_MORE
I am trying with this regex ^SOME_START_FORMAT_\d+$
. What I am doing wrong?
答案 0 :(得分:1)
you need to check for end of string instead of end of line so nothing after the digits will match (\z):
^SOME_START_FORMAT_\d+\z
for multiline this works at regxr.com
/^SOME_START_FORMAT_\d+$/gm
just have to add the multiline flag.
答案 1 :(得分:1)