[Top][All Lists]

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

Re: Negative Lookahead Equivalent in emacs

From: Emanuel Berg
Subject: Re: Negative Lookahead Equivalent in emacs
Date: Tue, 09 May 2017 09:16:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

> 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

I would probably use syntax classes [1] for
this, with numbered groups, as in this Elisp.
Regexps are hairy tho so some fiddling and
fine-tuning is expected:

    (when (re-search-forward
           "\\([[:graph:]]\\)[ \n]" (point-max) t)
      (goto-char (match-beginning 0))
      (message (match-string-no-properties 1)) )

Hello World!


underground experts united

reply via email to

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