[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 07:23:59 -0700 (PDT) |
User-agent: |
G2/1.0 |
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.
- Negative Lookahead Equivalent in emacs, luishenriquezperez, 2017/05/09
- Re: Negative Lookahead Equivalent in emacs, Emanuel Berg, 2017/05/09
- Re: Negative Lookahead Equivalent in emacs, hector, 2017/05/09
- Re: Negative Lookahead Equivalent in emacs, Wasell, 2017/05/09
- Re: Negative Lookahead Equivalent in emacs,
luishenriquezperez <=
- Re: Negative Lookahead Equivalent in emacs, Felix Dietrich, 2017/05/09
- Re: Negative Lookahead Equivalent in emacs, luishenriquezperez, 2017/05/09
- Re: Negative Lookahead Equivalent in emacs, luishenriquezperez, 2017/05/10