[ale] Single out a alarm with regex
Christopher Fowler
cfowler at outpostsentinel.com
Wed Oct 4 16:20:41 EDT 2006
On Wed, 2006-10-04 at 16:05 -0400, Alex LeDonne wrote:
> On 10/4/06, Christopher Fowler <cfowler at outpostsentinel.com> wrote:
> > I've started with a regex that looks like this:
> >
> > '^(DCH:.*?(MAINT).*$)'
> >
> > The outer '(' are there so I can capture the whole thing in $1.
> >
> > what I'm trying to do is create a regex that will catch anything that
> > matches this format:
> >
> > DCH: 0 <TYPE> ....
> >
> > I want th whole line but I do not want it if the type is 'MAINT'. What
> > I'm trying to do is get it to pass when the word MAINT is not in the
> > phrase. Can someone give me a pointer?
> >
>
> Does the language/regex engine in question support zero-width negative
> lookahead assertions?
>
> '^(DCH: .*? (?!MAINT).*$)'
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]
>
> I'm assuming that the space characters are part of the format. Use
> them to your advantage.
>
> -A
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list