[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] perl regexp question de'jour ;-)
- Subject: [ale] perl regexp question de'jour ;-)
- From: jknapka at kneuro.net (JK)
- Date: Fri, 07 Jul 2006 15:48:51 -0600
- In-reply-to: <[email protected]>
- References: <[email protected]>
Jim Popovitch wrote:
>My problem is this: Perl regexp matching seems to not be flexible (or
>my understanding of perl and/or regexp matching isn't broad enough) in
>that it doesn't allow me to specify a match condition for more
>parameters than actually exist. The above code will work as long as
>there are at least 2 params following the keyword "alert". If I use the
>following code, then option lines with less than 3 parameters are skipped.
>
> ------------------------
> }
> elsif ($ln =~ /^alert\s(\S+)\s(\S+)\s(\S+)/i) {
> my $email = $1
> my $interval = $2
> my $priority = $3
> ....
> }
> ------------------------
>
>Any examples on how to use perl regexp matching against a variable
>number of parameters?
>
>
If they're always going to be whitespace-delimited, I'd just
use split, instead of messing with regexps.
-- JK