> Is there a way to clear the matched subexpressions of the $1...$9
> variables or do I have to check each line to see what test applies?

Actually if you don't care what format the line is in, you can match all
three in one regex.  Use the [] regex operators to account for the three
different options in between you alphas.

Something like: 

/\s*([\w-_\.]+)\s*[ \:\*]\s*([\w-_\.]+)/

would load your alphas into $1 and $2 regardless of the format of the line.

HTHs

-Wayne

CAM Automation Programmer
Unicircuit Inc.
Littleton, Colorado
303-738-5390


 

> -----Original Message-----
> From: Am�rico Albuquerque [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 17, 2005 3:21 PM
> To: [email protected]
> Subject: Regexp question
> 
> Hi
> 
> I have a config file that can have three formats:
> "[alpha] [alpha]", "[alpha]: [alpha]" or "[alpha] *[alpha]"
> 
> So I made 3 regexp to check each variation:
> $line1 =~ /\s*([\w-_\.]+)\s+([\w-_\.]+)/;
> $line2 =~ /\s*([\w-_\.]+):\s*([\w-_\.]+)/;
> $line3 =~ /\s*([\w-_\.]+)\s+\*([\w-_\.]+)/;
> 
> the problem is that $1 and $2 keep the falues of the previous match.
> That means that I can't see if a match was foud unless I have to test it
> for each line.
> Is there a way to clear the matched subexpressions of the $1...$9
> variables or do I have to check each line to see what test applies?
> 
> Thanks in advance,
> Americo Albuquerque
> 
> 

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to