homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

regex: extract email embedded images

 10:06 pm on Oct 16, 2013 (gmt 0)

hi.. need some help..

how do i extract the src value using preg_match_all() in a string like...

d asda dsa as <img border=0 width=1024 height=291 id="_x0000_i1025" src="cid:image001.jpg@01CECA91.641305C0">d asda dsa das<br>d asd adsa a <img border=0 width=1024 height=727 id="_x0000_i1026" src="cid:image002.jpg@01CECA91.641305C0">d asdada dasd asd sad d ads ada

thanks for your answer in advance.. :)



 10:32 am on Oct 17, 2013 (gmt 0)

src ?= ?"([^"]+)"

The part in parentheses.

How consistent is the overall pattern? I'm seeing

<img border=0 width=\d+ height=\d+ id="\w+" src="cid:\w+\.jpg@\w+\.\w+">

but don't know how much of that would remain accurate in other cases. Is it always @01CECA91.641305C0 ?


 2:45 pm on Oct 17, 2013 (gmt 0)

You probably need to address the situation with multiple spaces and/or new lines between the "src" and the "=" (and same of the "=") and you probably need to also avoid it picking up on <script src="javahere.js"> -> so you need to make sure it's inside an <img> tag.
It's all essentially the same technique: you specify what's allow to match, and the part(s) between parentheses determine what you get as "output"

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved