zen0n has asked for the wisdom of the Perl Monks concerning the following question:

I am looking for a way to "break down" a regex expression into individual regex strings. for example
my $regex = "(^[1-3]|^yyy|^zzz)"; my @regexs = convert($regex); would create a list like $regexs[0] = "^1" $regexs[1] = "^2" $regexs[2] = "^3" $regexs[0] = "^yyy" $regexs[0] = "^zzz"
or some other equiv functionality :) Thanks

Replies are listed 'Best First'.
Re: Break down a regex expression into single regex?
by planetscape (Chancellor) on Feb 27, 2010 at 18:41 UTC
Re: Break down a regex expression into single regex?
by ww (Archbishop) on Feb 27, 2010 at 18:41 UTC

    Your pseudo-coded problem statement makes very little sense.

    1. read perldoc perlretut or any number of other documents re regexen.
    2. Change the capturing parens and perhaps add /g.
    3. Come back and show us what you've tried along with an explanation of how it fails, if that's the case