Is it possible to use both ^ and \G ?
my $string = " a 1 # "; my $i = 0; while () { if ( $string =~ /^\G\s+/gc ) { print "whitespace\n"; } elsif ( $string =~ /^\G[0-9]+/gc ) { print "integer\n"; } elsif ( $string =~ /^\G\w+/gc ) { print "word\n"; } else { print "done\n"; last; } }
desired output: whitespace word whitespace integer whitespace done
In reply to anchor ^ and \G by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |