Hi,
I'm trying to extract all four-digit numbers from a string in one fell swoop, but I can't seem to come up with the proper regexp. This is my first time using /g in a match so maybe there's a trick I'm missing.
For example, the string
"1111 2222aa3333 444 55555555 6666 7777-8888"
should yield
1111, 2222, 3333, 6666, 7777, 8888.
Here's one attempt that I thought had a reasonable chance.
- - - - - #!/usr/bin/perl -w my $foo = "1111 2222aa3333 444 55555555 6666 7777-8888"; my @a = ($foo =~ m'[\D^](\d{4})[\D$]'g); print "<$foo>\n"; print(join(":",@a)."\n"); - - - - -
<1111 2222aa3333 444 55555555 6666 7777-8888> 2222:3333:6666
Thanks for your consideration, Chap
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>