[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Negative Lookahead Equivalent in emacs

From: luishenriquezperez
Subject: Re: Negative Lookahead Equivalent in emacs
Date: Wed, 10 May 2017 08:51:25 -0700 (PDT)
User-agent: G2/1.0

On Tuesday, May 9, 2017 at 1:15:46 AM UTC-4, address@hidden 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  " › 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.

I edited the solution slightly so no new lines are included.


There are a lot of backslashes because I used regex-builder to test it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]