[ale] Single out a alarm with regex
Jason Day
jasonday at worldnet.att.net
Wed Oct 4 23:55:42 EDT 2006
On Wed, Oct 04, 2006 at 04:20:41PM -0400, Christopher Fowler wrote:
> I'm using standard PERL
>
> [cfowler at shuttle ~]$ echo "DCH: 0 MAINT INDICATION" | perl -le '$_ =
> <STDIN>;print "Yes [$1]" if m/^(DCH:.*(?!MAINT).*$)/'
> Yes [DCH: 0 MAINT INDICATION]
Hmm, it looks like you can't use a + or * quantifier with a negative
look-ahead assertion. In other words, you can use this regex:
^(DCH: +\d (?!MAINT).*$)
provided that there are exactly two spaces between the 0 and MAINT. But
this one *won't* work:
^(DCH: +\d +(?!MAINT).*$)
If you can't depend on the exact number of spaces, you could always do
something like:
if (/^DCH: +\d.*)$/ && $` ~! /MAINT/)
Jason
--
Jason Day jasonday at
http://jasonday.home.att.net worldnet dot att dot net
"Of course I'm paranoid, everyone is trying to kill me."
-- Weyoun-6, Star Trek: Deep Space 9
More information about the Ale
mailing list