SPUG: Regex that matches everything except a specific string

Yitzchak Scott-Thoennes sthoenna at efn.org
Thu Nov 6 21:33:33 CST 2003


On Thu, Nov 06, 2003 at 09:16:12AM -0800, Richard Anderson <richard at richard-anderson.org> wrote:
> I am trying to feed a regular expression to a mail processing program that
> matches every string except a specific string.  For example, I want a regex
> that does not match richard at richard-anderson.org but matches any other
> string.  If I were writing a Perl program, I would just do this:
> 
> if ($address !~ /^richard\@richard-anderson\.org$/) { print "Spam\n" }

/^(?!richard\@richard-anderson\.org\z)/



More information about the spug-list mailing list