help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: pattern-identification-data-extraction-format-string


From: Emanuel Berg
Subject: Re: pattern-identification-data-extraction-format-string
Date: Mon, 23 Mar 2015 02:40:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> Check this out:
>
>     (car (last (message-tokenize-header "From: Joe
> Hacker <get@this.data>" "<>") )) ; => get@this.data
>
> Is there a more general way to do that, something
> along the lines of:
>
>     (pattern-identification-data-extraction-format-string
> "From: Joe Hacker <get@this.data>" ".*<%1>" "This is
> the data I want: %1" )

I was directed to [1], section "Extracting submatches
from a regex match", so I put together

    (let ((header "From: Joe Hacker <get@this.data>"))
      (save-match-data
        (string-match "<\\(.*\\)>" header)
        (match-string 1 header) )) ; => "get@this.data"

Maybe my original solution to that particular problem
is just as good, but I asked for a generic way and
this seems to be it.

[1] http://www.emacswiki.org/emacs/ElispCookbook

-- 
underground experts united


reply via email to

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