in reply to How do I write a regex for 'does not contain' a string.

/^(?:[^f]+|f(?!oo))*$/; # Matches strings not containing 'foo'. /^(?:(?!PATTERN).)*$/; # Matches strings not containing PATTERN +.
The top one is reasonably fast, the bottom one is slow, but works for all patterns.

Abigail

Replies are listed 'Best First'.
Re: Re: How do I write a regex for 'does not contain' a string.
by IraTarball (Monk) on Aug 09, 2002 at 17:03 UTC
    Excelent! Thank you. I knew there must be a way to do this. Dispite the very valid points by fruiture and arturo about a better way to solve my particular problem, it was bugging me that I couldn't think of a way to do this.

    With much thanks,
    Ira

    "So... What do all these little arrows mean?"
    ~unknown