[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make regexp handling more regular
From: |
Daniel Martín |
Subject: |
Re: Make regexp handling more regular |
Date: |
Wed, 02 Dec 2020 22:28:31 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) |
Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> (when (setq match (rx-search-forward "p[a-z]+" nil t))
> (with-temp-buffer
> (insert (match match 0))
> (buffer-string)))
>
The way other Lisp-like languages like Clojure work is by returning
either nil (if no match), a string (if the regular expression matched
the string and didn't have any capture group), or a vector where the
first element is the entire match and the rest of elements are the group
matches.
I think it's a nice API, specially because you can use destructuring on
the return value to discern the cases.
- Re: Make regexp handling more regular, (continued)
Re: Make regexp handling more regular,
Daniel Martín <=
Re: Make regexp handling more regular, Juri Linkov, 2020/12/02
Re: Make regexp handling more regular, Adam Porter, 2020/12/02