So I have this expression
#(?<category>.+)(?:\/(?<id>.+))?
Which is supposed to capture the foo of #foo or capture both foo and bar of #foo/bar
However, it seems to match the entire rest of the string as foo and capture it

Removing the last functions as expected, but, of course, the last part is no longer optional

I don't understand why this happens. (This still happens without capture groups too)