((this)?|(that)?|(third_thing)?)
...
... I don't even trust it. ... there's probably 4 capture groups created as a result.
Just as an aside, the (?|(pat)|(te)|(rn)) "branch reset" pattern introduced with Perl version 5.10 will suppress the creation of a slew of captures in a case like this:
See Extended Patterns in perlre.c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $s = 'apathetic'; ;; my @captures = $s =~ m{ (pat) | (te) | (rn) }xms; dd \@captures; ;; @captures = $s =~ m{ (?| (pat) | (te) | (rn)) }xms; dd \@captures; " ["pat", undef, undef] ["pat"]
Give a man a fish: <%-{-{-{-<
In reply to Re^3: Regex result being defined when it shouldn't be(?)
by AnomalousMonk
in thread Regex result being defined when it shouldn't be(?)
by chenhonkhonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |