Regex to match 1 but not 10,11,12, etc or 21, 31, etc

regex

Solution

Would page=2 be ok? If not, I don't understand why you're doing this with regex. Using a substr/strpos/strcmp-equivalent function would be more appropriate.

In these examples, I'm assuming that `?page=1` is the end of the string.

If page=(a number from 0 to 9) would be ok, you need to use `\?page=\d$` (`\d means "a digit"`)

If page should only be 1, then it's `\?page=1$`

`$ = End of string`

The problem is that the `?` has a special meaning in regular expressions, and needs to be escaped.

Problem

I'm trying to find the proper regex to match: `?page=1` but I don't want to match `?page=10` or `?page=11` or `?page=12` ..etc to `?page=19` and I don't want to match `?page=21` or `?page=31` ...etc I just want to be able to match `?page=1` I've tried `?page=1[^0123456789]` but it doesn't seem to be working for me.

Original source