From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: luishenriquezperez@gmail.com Newsgroups: gmane.emacs.help Subject: Re: Negative Lookahead Equivalent in emacs Date: Wed, 10 May 2017 08:51:25 -0700 (PDT) Message-ID: <6f43469f-663e-4a7f-9811-384a43b2611a@googlegroups.com> References: <49e1dd7d-4be5-4b03-b9e2-e26b15b0a6cb@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1494432030 30832 195.159.176.226 (10 May 2017 16:00:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 10 May 2017 16:00:30 +0000 (UTC) Injection-Date: Wed, 10 May 2017 15:51:25 +0000 User-Agent: G2/1.0 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 10 18:00:22 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 1d8U2F-0007nZ-1P for geh-help-gnu-emacs@m.gmane.org; Wed, 10 May 2017 18:00:19 +0200 Original-Received: from localhost ([::1]:43431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8U2K-0005p7-Jc for geh-help-gnu-emacs@m.gmane.org; Wed, 10 May 2017 12:00:24 -0400 X-Received: by 10.99.135.198 with SMTP id i189mr2873702pge.83.1494431485655; Wed, 10 May 2017 08:51:25 -0700 (PDT) X-Received: by 10.157.28.130 with SMTP id l2mr143817ota.17.1494431485595; Wed, 10 May 2017 08:51:25 -0700 (PDT) Original-Path: usenet.stanford.edu!c26no409797itd.0!news-out.google.com!m134ni875itb.0!nntp.google.com!c26no409787itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <49e1dd7d-4be5-4b03-b9e2-e26b15b0a6cb@googlegroups.com> Complaints-To: groups-abuse@google.com Original-Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:18d:4700:a0f0:2163:74ba:a4d5:53a3; posting-account=1FnN2QoAAADplQTXU-CDH-RVhjZBEjLX Original-NNTP-Posting-Host: 2601:18d:4700:a0f0:2163:74ba:a4d5:53a3 Original-Xref: usenet.stanford.edu gnu.emacs.help:219116 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:112989 Archived-At: On Tuesday, May 9, 2017 at 1:15:46 AM UTC-4, luishenri...@gmail.com wrote: > 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 =E2=80=BA regex nirvana - nea= r 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. I edited the solution slightly so no new lines are included. \[^[:space:]\n\]\\(?:\[[:space:]\]\\|$\\) There are a lot of backslashes because I used regex-builder to test it.