RegEx for number and optional "/" after it

Viewed 22

I'm searching for a RegEx that searches for a fixed string, then a number and an optional "/" at the end, for example: /test/id30/ or /test/id30. My idea was to use

preg_match("/^\/test\/id\d+\/?$/i", $str, $matches);

But somehow it still doesn't recognize the "/" at the end. What's wrong?

Another note: somehow, other delimiters than "/" aren't recognized as RegEx. Maybe it has something to do with that?

Edit: I'm sorry, I forgot to copy the "/" at the beginning, but that wasn't the problem

0 Answers
Related