perl - Capturing Group with regex -



perl - Capturing Group with regex -

i using code follows,

code:

$str = 123455; if ($str =~ m/([a-z]+)|(\d+)/ { print "$1\n"; }

i know not print result because should give $2. want result using same code changing regular expression.

is possible it?

note :

please not provide result below,

$str = 123455; if ($str =~ m/(?:[a-z]+)|(\d+)/ { print "$1\n"; }

you can utilize (?| .. ) alternative capture grouping numbering,

use 5.010; # regex feature available since perl 5.10 $str = 123455; if ($str =~ m/(?| ([a-z]+)|(\d+) )/x) { print "$1\n"; }

regex perl

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -