The only thing in the file name that will change is the number after the "-" and before the .php. The number in the file name will range from 1 up to 99.

What I am trying to do is to (1) parse the url and grab the number portion of the filename, and (2) Use that number as a variable for other PHP functions on the page. In particular, the number will be assigned to a $thisPage variable. I then use $thisPage for previous/next page navigation through my photo galleries.

I currently assign the number for $thisPage manually, which is kind of a drag. Since this is the 21st century and because the $thisPage variable will always match the number used in the file name, I figured there was bound to be a way to use PHP to do this task!

I wouldn't treat it as a "URL", since you aren't doing anything URL-like with it. Just treat it as an ordinary string and manipulate it.

As always, there are many ways to do this. Here is one way...

This assumes that "-" (hyphen) only occurs (at most) once in the URL. The string is converted into an array (split on the hyphen). The second element of the array (eg. "3.php") is then converted to an integer (which effectively strips everything after the numeric part of the string). If there is no hyphen in the URL then $thisPage will be NULL. If there is no number after the hyphen then $thisPage will be 0 (zero).

AFAIK the hyphen does not have any special meaning outside of a character class, so it shouldn't need to be escaped here. (Even when inside of a char class it can be placed at the start (and some say end) of a class to negate its special meaning - so, I don't think it ever really needs to be escaped?)

It depends on the RegEx engine. Different applications use the underlying language in different ways. If you're using something new, it's worth doing a meta-test: does escaping something that doesn't need to be escaped have any effect? For example, if \a has no special meaning then check whether \a is interpreted as a.