Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 28th, 2012, 10:28 PM
-Dman100- -Dman100- is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 141 -Dman100- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 21 m 55 sec
Reputation Power: 10
Detect From: email address

I am trying to match on a from email address in a forwarded email thread. The email can be forwarded multiple times with various types of formats of the From: email address. I only need to get the last one, but it has to be the "From:" email address.

I've tried three versions, which are close, but not quite right.

From: [^\\[]+\\[mailto:([^@]+@[^]]+)\\]
From: [^<]+<([^@]+@[^>]+)>
From: [^<]+<+mailto:+([^@]+@[^>]+)>

Thanks for any help.

Last edited by requinix : July 29th, 2012 at 02:40 AM.

Reply With Quote
  #2  
Old July 29th, 2012, 03:33 PM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 203 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 16 h 10 sec
Reputation Power: 41
Show us some examples of what you are trying to match.

Reply With Quote
  #3  
Old July 29th, 2012, 04:11 PM
ragax's Avatar
ragax ragax is offline
Turn left at the third duck
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Location: Nelson, NZ
Posts: 93 ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 24 m 37 sec
Reputation Power: 92
Hi Dman100,

The email headers can vary wildly.
What would help most is if you would paste a sample email header, highlighting the line to be matched.

To see the full email with the headers, in Gmail, you select "show original" from the drop-down menu at the right of the message. In Horde, outlook, other programs, it might say "show full message", "show headers", etc.

Wishing you a fun week.
__________________
Regex Tutorial | Latest RegexBuddy Demo

Reply With Quote
  #4  
Old July 29th, 2012, 05:05 PM
-Dman100- -Dman100- is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 141 -Dman100- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 21 m 55 sec
Reputation Power: 10
Here are a few examples:

Code:
From: Cole, Amy [mailto:acole-rms@STERICYCLE.com] 
Sent: Tuesday, July 10, 2012 1:59 PM 
To: Sunovion O/E 
Subject: Request for RGA 

Please submit an RA for each of the attached Debit Memos. 

Thank You 

Amy Cole 
RA Associate - Retail Returns 
Stericycle 
acole-rms@stericycle.com<mailto:acole-rms@stericycle.com> 
2670 Executive Drive 
Suite A 
Indianapolis, IN 46241 
p (317) 217-6731 
f (317) 217-6761 
[image001.jpg] 


this should detect: acole-rms@STERICYCLE.com

Here is another:

Code:
From: Mathai, Julia 
Sent: Thursday, June 07, 2012 9:57 AM 
To: 'Ashley Orf' 
Subject: RE: Debit Memo # 28057 

please see the attached RAs 


Julia Mathai 
Order Management Specialist 

Direct 508-357-7826 I Fax 508-787-4191 l Email julia.mathai@sunovion.com<mailto:julia.mathai@sunovion.com> 





________________________________ 
From: Ashley Orf [mailto:returns@totalrxreturns.com] 
Sent: Thursday, June 07, 2012 9:47 AM 
To: Mathai, Julia 
Subject: Debit Memo # 28057 

Debit Memo #28057 product was destroyed in house on 2/13/12 


This one should detect: returns@totalrxreturns.com

Looking to get the last From: email address in the forwarded thread.

Does that help?

Reply With Quote
  #5  
Old July 29th, 2012, 06:04 PM
ragax's Avatar
ragax ragax is offline
Turn left at the third duck
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Location: Nelson, NZ
Posts: 93 ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 24 m 37 sec
Reputation Power: 92
Yes, it helps! Thank you.

This regex will match your addresses.

Code:
(?i)mailto:\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b


(The (?i) is a case-insensitive flag, depending on what you are using, you may have a different flag.)

In your language, you find all the matches with this regex. Then you take the last one.

Are you on php?
If so, first you define
PHP Code:
 $regex '~(?i)mailto:\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b~'


(Note the tilde delimiters.)
Then you match everything:
PHP Code:
 $found preg_match_all($regex,$email,$matches,PREG_SET_ORDER); 

Then you look at the number of matches:
PHP Code:
 $size count ($matches); 


Then you display the last match:
PHP Code:
 $last $matches[$size-1][0]; 


If you put parentheses around the email address (between the two \b tags), then you can display it in the same way, by showing Group 1:
PHP Code:
 $last $matches[$size-1][1]; 


Okay, I only typed this in the window without testing. There might be a typo but it would probably be minor.

Pls let me know if this helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Detect From: email address

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap