From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: email extraction in emacs Date: Fri, 1 Dec 2006 01:37:10 -0600 Organization: UseNetServer.com Message-ID: References: <1164819237.355277.217960@j72g2000cwa.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1164958880 30098 80.91.229.2 (1 Dec 2006 07:41:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 1 Dec 2006 07:41:20 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 01 08:41:17 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gq31D-0007bG-Ks for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Dec 2006 08:41:11 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gq31D-0004D7-4t for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Dec 2006 02:41:11 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!208.49.83.154.MISMATCH!uns-out.usenetserver.com!news.usenetserver.com!pc02.usenetserver.com!DIALUPUSA.NET!not-for-mail Original-Newsgroups: gnu.emacs.help X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Original-X-Complaints-To: abuse@usenetserver.com Original-Lines: 32 Original-X-Trace: a5fdb456fdba9a13a039a02771 Original-Xref: shelby.stanford.edu gnu.emacs.help:143555 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:39157 Archived-At: "Mathias Dahl" wrote in message news:u64cxccle.fsf@gmail.com... > "a" writes: > > > if i have a text file filled with email addresses but other things > > as well what commands can i use to extract the email address from > > the file? > > You would probably need `search-forward-regexp' and > `match-string'. The code below will not work but it will give you an > idea on how to do it: > > (defun blah () > (let (adresses) > (while (search-forward-regexp "\\(REGEXP-MATCHING-EMAILS\\)" nil t) > (setq addresses (append adresses (list (match-string 1))))) > adresses) > > Matching e-mail addresses using a regexp can be tricky, if you want to > support all variants (with `+' before the @ and such). This sort of works interactively, that is it finds most of them. Blah is missing a final parenthesis and I don't understand if addresses with 2 d's is outside the scope of the let or not. Anyway, it just returns a list of nils even if some email addresses are below the point of invocation in *scratch. \b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]\{2,4\}\b Maybe all of the backslashes have to be doubled.