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
aa 444 -
should yield
I think this might work.
/\b\d{4}\b/
Rob
-Original Message-
From: Chap Harrison [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 30, 2004 10:38 AM
To: [EMAIL PROTECTED]
Subject: Trouble with m///g
Hi,
I'm trying to extract all four-digit numbers from a string in one fell
swoop
For example, the string
aa 444 -
should yield
, , , , , .
That's actually kind of tricky. How about:
$aa = aa 444 -;
@aa = $aa =~ /(?!\d)\d{4}(?!\d)/g;
print $_\n for @aa;
That gets and
with the '-'
Rob
-Original Message-
From: Chap Harrison [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 30, 2004 10:38 AM
To: [EMAIL PROTECTED]
Subject: Trouble with m///g
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
30, 2004 10:38 AM
To: [EMAIL PROTECTED]
Subject: Trouble with m///g
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
Chap Harrison wrote:
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
aa 444
Chap Harrison wrote:
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
aa 444
On Sep 30, 2004, at 9:55 AM, Wiggins d Anconia wrote:
Out of curiousity based on your description shouldn't it return,
:::::::
Or do you really mean, you are trying to capture all 4 digit strings
that are not in a string of longer digits? You need to be very
TIMTOWTDI:
@list = grep length==4, /\d+/g
Shouldn't that be:
@list = grep length==4, $foo =~ /\d+/g;
Cool solution, I wouldn't have thought to do it that way. I'm getting
varying Benchmarking results, though. I think it might have something
to do with grep speedups from 5.6.1 to 5.8.0...
Chap Harrison wrote on 30.09.2004:
On Sep 30, 2004, at 9:55 AM, Wiggins d Anconia wrote:
Out of curiousity based on your description shouldn't it return,
:::::::
Or do you really mean, you are trying to capture all 4 digit strings
that are not in a string
On Sep 30, 2004, at 10:41 AM, Jan Eden wrote:
my @a = ($foo =~ m'(?!\d{4})\d{4}(?!\d)'g);
Careful, you mistyped the original proposition:
my @a = ($foo =~ m'(?!\d)\d{4}(?!\d)'g);
Oops, sorry - I copied that into the email from Wiggins' reply, but
actually tested with Dave Gray's. Didn't notice
11 matches
Mail list logo