From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Wasell Newsgroups: gmane.emacs.help Subject: Re: Negative Lookahead Equivalent in emacs Date: Tue, 9 May 2017 11:54:27 +0200 Organization: NeverYouMind, Inc. Message-ID: References: <49e1dd7d-4be5-4b03-b9e2-e26b15b0a6cb@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1494323740 7703 195.159.176.226 (9 May 2017 09:55:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 9 May 2017 09:55:40 +0000 (UTC) User-Agent: MicroPlanet-Gravity/3.0.4 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 09 11:55:35 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d81rh-0001p0-JW for geh-help-gnu-emacs@m.gmane.org; Tue, 09 May 2017 11:55:33 +0200 Original-Received: from localhost ([::1]:36202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d81rn-0002lw-4X for geh-help-gnu-emacs@m.gmane.org; Tue, 09 May 2017 05:55:39 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!feeder.erje.net!2.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-Injection-Info: mx02.eternal-september.org; posting-host="fea69ecea5ba4b6b81152c4c5023f9b9"; logging-data="5896"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Tod8RmYT8l3vuOgnd3d6f" Cancel-Lock: sha1:XXTHmJDcCQ0Jv8qEINlJtci/C88= Original-Xref: usenet.stanford.edu gnu.emacs.help:219112 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112976 Archived-At: On Mon, 8 May 2017 22:15:42 -0700 (PDT), in article <49e1dd7d-4be5-4b03-b9e= 2- e26b15b0a6cb@googlegroups.com>, luishenriquezperez@gmail.com wrote: >=20 > Hi, >=20 > I'm trying to write a regex that matches the last character of a sequence= of non-whitespace characters '[^\n\r\t\f ]', or an empty line matching ^$.= =20 >=20 > Thus:=20 > Hello World! --> "o" and "!" would be matched >=20 > In non-elisp regex languages I know the code for this is: \S(?!\S)=20 > I know that \S is equivalent too [^ /n/r/t/f].=20 > But I'm unsure of what the elisp equivalent (if any) of the negative look= ahead (?!). >=20 > I saw on this forum a post "gnu.emacs.help ? regex nirvana - near miss" > Where Drew Adams said: "Typically, what you want to do for this in Emacs = Lisp is to combine=20 > the use of a regexp for positive matching with other code that takes=20 > care of the non-matching (negation) need. " >=20 > However, I'm not sure how to go about doing this. If I'm not miss-understanding you completely, you want to match a non- whitespace, followed either a whitespace or an end-of-line. That would be: =09[^[:space:]]\(?:[[:space:]]\|$\) Am I missing something?