Help for this page
my $s = "123 45 6 789"; while ($s =~ m/\d+/g) { print "> $&\n"; }
> 123 > 45 > 6 > 789
my $s = "123 carrots 45 6 bananas 789"; while (1) { ... $s =~ /\G([a-z]+)/gc and print "WORD $1\n" and next; $s =~ /\G$/gc and last; }
NUMBER 123 SPACE ... WORD bananas SPACE NUMBER 789
NUMBER 123 NUMBER 45 NUMBER 6 NUMBER 789
my $s = "123 carrots 45 6 bananas 789"; while ($s =~ /(\d+)/g) { print "'$1' at position ", pos($s)-length($1), "\n"; }
'123' at position 0 '45' at position 15 '6' at position 18 '789' at position 29
my $s = "123 carrots 45 6 bananas 789"; while ($s =~ /(\d+)/g) { print "'$1' at position ", pos($s)-length($1), "\n"; pos($s) += 13; }
'123' at position 0 '5' at position 16 '89' at position 30
www.com | www.net | www.org
No recent polls found