in reply to Regex: succeeds, but parens don't collect...

What you have is an other group (with a typo, but that doesn't matter, even if you switch the : and ?, you still get the same result), and tell Perl to match that group zero or more times.

Such a regexp will always match, and always at the beginning of the string. In your case, it matches the empty string. So, the optional still matches, but it doesn't match what you think it will match.

Why you have the outer (?: )? construct anyway isn't clear to me.

  • Comment on Re: Regex: succeeds, but parens don't collect...