in reply to regex needed: Capture a single entity from two discontiguous parts.

my $number = $1 if $string =~ m/\(([\d,]+)\)/; $number =~ s/,//g; # how I would approach the problem...

It doesn't seem like a terribly complicated problem as is, but I do wonder if there's a good way to capture the digits in $string if there are an unknown number of commas — without needing to have a second regex.

-Paul

Replies are listed 'Best First'.
Re^2: regex needed: Capture a single entity from two discontiguous parts.
by Anonymous Monk on Dec 23, 2006 at 16:03 UTC
    That's what I was currently doing. I just hoped I could do it in the regex, no big deal I guess. Thanks