[ale] Single out a alarm with regex

Alex LeDonne aledonne.listmail at gmail.com
Thu Oct 5 09:58:08 EDT 2006


On 10/5/06, Christopher Fowler <cfowler at outpostsentinel.com> wrote:
> I guess I was wanting a simple regex.
>
> Here is what I do know about the alarm
>
> 1.  It starts with 'DCH:'
> 2.  There are any number of characters between the DCH and the type.
> The type in the example is 'MAINT INDICATION'.
> 3.  I want every alarm with the exception of 'MAINT INDICATION'.
>
> That is why I started out with the simple one.  I do not know how many
> digits or even if they are digits that come after the DCH.  I do know
> that it is at least one character.
>
Can anything come after the type? Or, more particularly, can anything
come after the type if the type is "MAINT INDICATION" ? Finally, is
there guaranteed to be at least one whitespace character preceding the
type? This is critical if you want the zero-width assertion to work...
if you have .* immediately before a zero-width negative lookahead,
when the negative assertion blocks the match, the engine will
backtrack and .* will consume the next character, the negative no
longer blocks, and the pattern matches.

Ex.:
aledonne at rumba:~> echo "foobarbaz" | perl -le '$_=<STDIN>; print "Got
$1 and $2" if m/^foo(.*?)(?!bar)(.*$)/'
Got b and arbaz

-A



More information about the Ale mailing list