in reply to Limiting number of regex matches
#!/usr/bin/perl -- use strict; use warnings; use Data::Dump; my $str ='dog dog dog dog dog'; my @dogs ; while( @dogs < 3 and $str =~ /(dog)/g ){ push @dogs, $1; } dd \@dogs; __END__ ["dog", "dog", "dog"]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Limiting number of regex matches
by 2teez (Vicar) on Sep 25, 2012 at 21:06 UTC | |
by Anonymous Monk on Sep 25, 2012 at 22:19 UTC | |
by 2teez (Vicar) on Sep 25, 2012 at 23:42 UTC | |
by Anonymous Monk on Sep 25, 2012 at 23:51 UTC |