I'm trying to match only the /blog?page=1
(only with page=1
) and I have written the regex for it that is /blog\?page=1
but it is also matching with /blog?page=11
. Is this possible only to match it with /blog\?page=1
?
I'm trying to match only the /blog?page=1
(only with page=1
) and I have written the regex for it that is /blog\?page=1
but it is also matching with /blog?page=11
. Is this possible only to match it with /blog\?page=1
?
You need to use anchors: \/blog\?page=1$
. This will assert the position at end of the string.
Now, depending on what your are trying to match, if you are looking for the first digit only, for example, you can use this: \/blog\?page=\d
. You can also use a capture group, to retrieve just the number: \/blog\?page=(\d)
.