http://qs321.pair.com?node_id=11106667


in reply to Complex regex question

Hi

words boundaries?

$string_three =~ m{\b ( [ab] \d+ | \d+ [ab] ) \b }gx

what are the undefs in my @results?

List context for match groups

Replies are listed 'Best First'.
Re^2: Complex regex question
by AnomalousMonk (Archbishop) on Sep 25, 2019 at 06:58 UTC

    But Cody Fendant seems to want the alpha and numeric fields extracted separately. The  m{\b ( [ab] \d+ | \d+ [ab] ) \b }gx regex requires a subsequent (albeit simple) step to achieve this:

    c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $string_three = 'foo bar [21a] plus (b23) baz bax'; my @string_three_results = $string_three =~ m{\b ( [ab] \d+ | \d+ [ab +] ) \b }gx; dd \@string_three_results; " ["21a", "b23"]


    Give a man a fish:  <%-{-{-{-<