in reply to Re: Regex: Matching quoted text
in thread Regex: Matching quoted text

If you use /^(?:"([^"]+)"|(-))$/, the matching expression is not always in the same variable, but it is always in $1 || $2 :)
Eh, no. Consider:
"0" =~ /^(?:"([^"]+)"|(-))$/;
Then $1 || $2 is actually undefined (because $1 is 0, hence false, and $2 is undefined). If the OP uses 5.10 or later, he could use $1 // $2, but then there's a better solution available as well (see my other post).

Replies are listed 'Best First'.
Re^3: Regex: Matching quoted text (!!'-')
by tye (Sage) on Jun 04, 2010 at 03:46 UTC