
shawnhcorey
Enthusiast

Feb 19, 2010, 5:30 AM
Post #2 of 3
(1617 views)
|
|
Re: [kk2950] How to write the function this regular expression
[In reply to]
|
Can't Post
|
|
Well, if the question was written in English, it would be easier to understand. Do they mean: Write a function to extract sequences of 3 digits from a string?
#!/usr/bin/perl use strict; use warnings; sub foo { my @sequences = (); for my $string ( @_ ){ my @seqs = $string =~ m{ [[:digit:]]{3} }gmsx; push @sequences, @seqs; } return @sequences; } print foo( 'ab25AEBT312ab!!!' ); __END__ I love Perl; it's the only language where you can bless your thingy. Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib. Get Markup Help. Please note the markup tag of "code".
|