Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: anchor ^ and \G
by kcott (Archbishop) on Jun 27, 2015 at 23:57 UTC | |
by Anonymous Monk on Jun 28, 2015 at 00:00 UTC | |
|
Re: anchor ^ and \G
by roboticus (Chancellor) on Jun 28, 2015 at 00:26 UTC | |
by ikegami (Patriarch) on Jun 30, 2015 at 19:37 UTC | |
|
Re: anchor ^ and \G
by stevieb (Canon) on Jun 28, 2015 at 00:34 UTC | |
|
Re: anchor ^ and \G
by GrandFather (Saint) on Jun 28, 2015 at 00:16 UTC | |
|
Re: anchor ^ and \G
by ww (Archbishop) on Jun 28, 2015 at 00:17 UTC |