From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Negate a regexp Date: Mon, 19 Apr 2010 08:51:23 -0700 Message-ID: <8282B0BC46B0423AA171693F27FF1D22@us.oracle.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1271692371 16739 80.91.229.12 (19 Apr 2010 15:52:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 19 Apr 2010 15:52:51 +0000 (UTC) To: "'Leo'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 19 17:52:50 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O3tHE-0000ph-Ok for geh-help-gnu-emacs@m.gmane.org; Mon, 19 Apr 2010 17:52:49 +0200 Original-Received: from localhost ([127.0.0.1]:48687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3tHE-0006tX-2A for geh-help-gnu-emacs@m.gmane.org; Mon, 19 Apr 2010 11:52:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O3tG5-0006Dy-C1 for help-gnu-emacs@gnu.org; Mon, 19 Apr 2010 11:51:37 -0400 Original-Received: from [140.186.70.92] (port=56071 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3tG3-0006CY-Hq for help-gnu-emacs@gnu.org; Mon, 19 Apr 2010 11:51:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O3tG1-0005ec-Nm for help-gnu-emacs@gnu.org; Mon, 19 Apr 2010 11:51:35 -0400 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:29944) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O3tG1-0005eC-HW for help-gnu-emacs@gnu.org; Mon, 19 Apr 2010 11:51:33 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o3JFpQSx008764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Apr 2010 15:51:28 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o3JEOjWY006415; Mon, 19 Apr 2010 15:51:26 GMT Original-Received: from abhmt006.oracle.com by acsmt355.oracle.com with ESMTP id 187977811271692284; Mon, 19 Apr 2010 08:51:24 -0700 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Apr 2010 08:51:24 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Thread-Index: Acrf0OmrUopWn39/TJCOGQo+eeumOQABWZnA X-Auth-Type: Internal IP X-Source-IP: acsinet15.oracle.com [141.146.126.227] X-CT-RefId: str=0001.0A090208.4BCC7C00.0161:SCFMA922111,ss=1,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:72757 Archived-At: > How to negate a regexp? For example this one: \(?:\sw\|\s_\|\s\\). You cannot express a complement using (real) regexps. Regular expressions are just not that expressive (powerful). However, Emacs Lisp is that powerful; its use of regexps is not limited to real regular expressions; and you can bathe your use of regexps in a more powerful sauce. In Emacs Lisp, you can in some cases use complementary syntax: \W as complement of \w, \S_ as complement of \s_, etc. And you can use ^ at the beginning of a [...] character set to complement that set (what the manual calls a "complemented character alternative"). See node `Syntax of Regexps' in the Elisp manual. Another thing you can do is to use a regexp to determine a set of matches - those elements you do not want, and then, assuming you know the overall domain explicitly (extensively), subtract those matches to get the complement (those elements of the domain that do not match).