Alternation is constrained only by grouping parens, or by the pattern as a whole. In your case, you've got two alternates of choice:
(.*)EDITION/
...or...
Edition/
Whichever of those alternates matches will be captured into $1. $2 will only be populated if the first alternate is matched, however. $3 will always be populated with something (assuming the overall pattern match is successful), even if that something is an empty string; it takes place outside of the alternation.
The \/ construct equates to the literal forward slash. It has to be escaped with a backslash so that it doesn't get confused with the m// operator's terminating /.
As for your last question: $1 will get everything matched by (.*)EDITION\/|Edition\/. $2 will get everything matched by the first (.*), but only if the first alternate in your alternation is matched. $3 will get everything matched by the final (.*).
What are you actually wanting to match? Is it true that you only want $2 to be populated with a useful value if the text contains EDITION/, but not if it contains Edition/?
|