On May 10, Dave K said:
>"Jeff 'Japhy' Pinyan" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> On May 10, Dave K said:
>>
>> >while () {
>> > if ( m/,$p1|$p2|$p3|$p4|$p5|$p6|$p7|$p8,/ ) {
>>
>> You need ()'s around the $p1|$p2|... part. The regex
>>
>> /,a
on Fri, 10 May 2002 14:55:08 GMT, [EMAIL PROTECTED]
(Dave Chappell) wrote:
> (/,[512..520|528..568|576..578|592..600|608..622|624..670|672..685|
> 768..771] ,/){
The range operator doesn't work as you want in a regex character
class, and neither does the '|'.
I would do it like this:
#! perl
No I don't see why I need (). (but I do see an opportunity to learn
something...). The kludge I posted does work (with the sample data in the
original post). Why would () be required? If I understood the post
correctly the task did not require capturing any numbers.
TIA
"Jeff 'Japhy' Pinyan" <[EM
On May 10, Dave K said:
>my $p1 = join('|', (512..520));
>my $p2 = join('|', (528..568));
>my $p3 = join('|', (576..578));
>my $p4 = join('|', (592..600));
>my $p5 = join('|', (608..622));
>my $p6 = join('|', (624..670));
>my $p7 = join('|', (672..685));
>my $p8 = join('|', (768..771));
Why not
On May 10, Dave Chappell said:
>I read a file line by line, on each line if any numbers in the range
>specified below exist between comas,
>
>Example:
>Line 1> hello,world,123,,
>Line 2> The grass,456, is,greener,
>Line 3> On,533,the,other, side
>Line 4> As, long, as the,1,grass is watered
Dave,
One possiblity:
use strict;
open(IN, "lfile.txt"); # ho;d the line from the example in the orig post
my $p1 = join('|', (512..520));
my $p2 = join('|', (528..568));
my $p3 = join('|', (576..578));
my $p4 = join('|', (592..600));
my $p5 = join('|', (608..622));
my $p6 = join('|', (624..6
oops...forgot parens around the \d+...
- Original Message -
From: "Tanton Gibbs" <[EMAIL PROTECTED]>
To: "Dave Chappell" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, May 10, 2002 11:22 AM
Subject: Re: Matching a range
> Unfortunately, t
tions and break out of processing the current regex. It will then
continue on to the next line.
- Original Message -
From: "Dave Chappell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 10, 2002 10:55 AM
Subject: Matching a range
> I read a file lin
I don't think you can "or" in the middle of a character class. I think that
if you wanted to use that approach, you should have a separate character
class for each "or".
-Original Message-
From: Dave Chappell
To: [EMAIL PROTECTED]
Sent: 5/10/02 7:55 AM
Sub
I read a file line by line, on each line if any numbers in the range
specified below exist between comas,
Example:
Line 1> hello,world,123,,
Line 2> The grass,456, is,greener,
Line 3> On,533,the,other, side
Line 4> As, long, as the,1,grass is watered
Line 5> Bye,world,680,,
print the line
10 matches
Mail list logo