From: "Wolfgang Nádasi-Donner" Date: 2005-04-29T18:59:27+09:00 Subject: Re: Inverting a regular expression? "Harry Ohlsen" schrieb im Newsbeitrag news:13AE96A47C1FF1498AEED9C5D6AEC449BA5E05@apsgpexm01.hyperion.com... > A colleague of mine just asked me whether it was possible to invert an > arbitrary regular expression. Ie, create a new regular expression that > matches whatever the original *didn't*. > It is impossible in general terms if you are talking about the usual "extended regular expressions" (I didn't think about the "real regular expressions"). Take the RegEx /(.{4})xy\1/ First of all - what does it mean to invert this expression? Second - the pattern, that is produced by the RegEx is not static, it is build on results from applying parts of the pattern. I assume you can handle this by applying the RegEx (=pattern) to a string and use the MatchData-Object to find out, what parts of the string are not matched. Wolfgang N�dasi-Donner wonado@donnerweb.de