Re: numbers and strings and regex?
- From: Brian McCauley <nobull@xxxxxxxx>
- Date: Mon, 30 May 2005 18:30:42 +0100
Geoff Cox wrote:
I have a series of files such as
blue-green-01-01.doc to blue-green-01-09
blue-green-01-11 up to
blue-green-01-32
and am trying to evaluate the second set of 2 digits using File::Find and this bit of code
if ($name =~ /.*?(\d{2})-((\d{1})(\d{1}))\.jmx/i) {
my $both = $2;
my $first = $3;
my $second = $4;
if ($4 <= 9) { $exnum = $4; } else {my $exnum = $both; }
obviously something wrong here - where am I wrong?
Rather hard to know where to start at a guess the central problem is that $4 is a single digit so ( $4 <= 9 ) is always true. You are also capturing subexpressions you don't need.
You you appear to be delaring $esnum in the wrong place.
I also suspect you be anchoring your regex to the end of the string raher than using .* to find the last match.
Perhaps you should try something simple like...
if ($name =~ /\d{2}-(\d{2})\.jmx$/i) {
my $exnum = 0+$1;
}
.- Follow-Ups:
- Re: numbers and strings and regex?
- From: Geoff Cox
- Re: numbers and strings and regex?
- From: Geoff Cox
- Re: numbers and strings and regex?
- References:
- numbers and strings and regex?
- From: Geoff Cox
- numbers and strings and regex?
- Prev by Date: Re: http auth logindialog box
- Next by Date: Re: http auth logindialog box
- Previous by thread: Re: numbers and strings and regex?
- Next by thread: Re: numbers and strings and regex?
- Index(es):
Relevant Pages
|