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 07:23:59 -0700 (PDT) Message-ID: <603a9ada-a1ed-4630-bd8c-40504a9e36e6@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 X-Trace: blaine.gmane.org 1494426400 32143 195.159.176.226 (10 May 2017 14:26:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 10 May 2017 14:26:40 +0000 (UTC) Injection-Date: Wed, 10 May 2017 14:23:59 +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 16:26:36 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 1d8SZX-0008Fb-O5 for geh-help-gnu-emacs@m.gmane.org; Wed, 10 May 2017 16:26:35 +0200 Original-Received: from localhost ([::1]:43045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8SZd-0007Gf-Bh for geh-help-gnu-emacs@m.gmane.org; Wed, 10 May 2017 10:26:41 -0400 X-Received: by 10.13.228.197 with SMTP id n188mr2853733ywe.156.1494426239450; Wed, 10 May 2017 07:23:59 -0700 (PDT) X-Received: by 10.157.40.242 with SMTP id s105mr132035ota.5.1494426239394; Wed, 10 May 2017 07:23:59 -0700 (PDT) Original-Path: usenet.stanford.edu!t26no230221qtg.1!news-out.google.com!m134ni827itb.0!nntp.google.com!c26no380697itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Original-Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:18d:4700:a0f0:8d34:7f9a:b264:e0e2; posting-account=1FnN2QoAAADplQTXU-CDH-RVhjZBEjLX Original-NNTP-Posting-Host: 2601:18d:4700:a0f0:8d34:7f9a:b264:e0e2 Original-Xref: usenet.stanford.edu gnu.emacs.help:219115 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:112987 Archived-At: On Tuesday, May 9, 2017 at 5:54:29 AM UTC-4, Wasell wrote: > On Mon, 8 May 2017 22:15:42 -0700 (PDT), in article <49e1dd7d-4be5-4b03-b9e2- > e26b15b0a6cb@googlegroups.com>, luishenriquezperez@gmail.com wrote: > > > > Hi, > > > > 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 ^$. > > > > Thus: > > Hello World! --> "o" and "!" would be matched > > > > In non-elisp regex languages I know the code for this is: \S(?!\S) > > I know that \S is equivalent too [^ /n/r/t/f]. > > But I'm unsure of what the elisp equivalent (if any) of the negative lookahead (?!). > > > > 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 > > the use of a regexp for positive matching with other code that takes > > care of the non-matching (negation) need. " > > > > 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: > > [^[:space:]]\(?:[[:space:]]\|$\) > > Am I missing something? No you're not missing anything. This one is a lot simpler :). Thank you.