[Javascript] Inverting a regex pattern
David Lovering
dlovering at gazos.com
Sun May 1 10:53:36 CDT 2005
Here's another question that I'm sure can be answered quickly, and then I'll
spend the next month feeling stupid for having asked it --
Is there a quick-and-dirty way of creating a complementary regular
expression, given another? For example, if somebody gives me
var re = /^\([2-9][0-9]{2}\)\b[2-9][0-9]{2}\-[0-9]{4}$/;
[a rather crude phone number pattern-match], can I do something like
var not_re = /[^(re)]?/; // obviously invalid, for a number of
very good reasons //
to look for the shortest string which violates the original pattern? If I
could come up with something like that, my life would be complete and I
would lack for nothing... [***]
-- Dave Lovering
*** Obviously a corollary of the "simple pleasures for simple minds" adage
More information about the Javascript
mailing list