From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: pattern-identification-data-extraction-format-string
Date: Mon, 23 Mar 2015 02:40:32 +0100 [thread overview]
Message-ID: <87a8z4lcdr.fsf@debian.uxu> (raw)
In-Reply-To: 87sicwlgk1.fsf@debian.uxu
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
next prev parent reply other threads:[~2015-03-23 1:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 0:10 pattern-identification-data-extraction-format-string Emanuel Berg
2015-03-23 1:40 ` Emanuel Berg [this message]
2015-03-24 2:32 ` pattern-identification-data-extraction-format-string Emanuel Berg
2015-03-24 8:03 ` pattern-identification-data-extraction-format-string Philipp Stephani
[not found] ` <mailman.2660.1427184219.31049.help-gnu-emacs@gnu.org>
2015-03-25 0:58 ` pattern-identification-data-extraction-format-string Emanuel Berg
2015-03-25 1:03 ` pattern-identification-data-extraction-format-string Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a8z4lcdr.fsf@debian.uxu \
--to=embe8573@student.uu.se \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.