Sometimes you want to match something optionally, meaning it can be there or not and it will still match. You do this with the '?' (question-mark) character. Simply put it after the regex symbol or set you want to be optional and you'll see it match. Here's a few URLs to try this on:
/blog/article/1 /blog/article/ /blog/article/2
Just a few URLs but imagine you want to match any of those as being the same thing. To do that you just put a '?' at the end and it will optionally match the [0-9] character set. I'm going to write one regex but it's in verbose mode so I can comment on each character and you can see it:
^/blog/article/[0-9]?$
^ # from the start
/blog/article/
[0-9] # any of 0-9
? # optional though
$ # to the end
First I have the regex like normal, then I wrote it out verbose. Let's walk through how the engine would match the first of our regex:
When you run this you should see it match all of these URLs twice, since we have the regex repeated in verbose form for you