Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Mailto regex

Last post 11-05-2009, 5:38 PM by Aussie Susan. 3 replies.
Sort Posts: Previous Next
  •  11-05-2009, 7:07 AM 57161

    Mailto regex

    Hello i have question about write a pattern that will find all the emails at a webpage in a mailto syntax

    i wrote something like this

    $pattern_email = '[a-zA-Z0-9]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9]+[.a-zA-Z0-9]+?';
    $pattern = '#<a href="?\'?mailto:'.$pattern_email.'"?\'?>('.$pattern_email.')</a>#';

    But this pattern only works for so defined strings

    <a href="mailto:email@domain.com">email@domain.com</a>

    I need do something more complex to find for example somthing like this 

    <a href="mailto:email@domain.com"><strong>email@domain.com</strong></a>
    <a title="Linkinfication: mailto:email@domain.com" href="mailto:email@domain.com" class="any css class">email@domain.com</a> 

    Filed under:
  •  11-05-2009, 11:24 AM 57165 in reply to 57161

    Re: Mailto regex

    Is it just me or does anyone else think this is so more email spam can be sent?

    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
  •  11-05-2009, 3:59 PM 57172 in reply to 57165

    Re: Mailto regex

    wrrr *** and what shuld i do now i didn't expect such an answer the reson to do that, is that my buyer want to protect his allredy existing website, and the scritp is changing all the mailto tags into image you can se this here bayer.com.pl/email_filter/index and i told them that i can do this but i didnt expected such thing like this

    http://www.bayer.com.pl/content/42/press_room/65  look at the and of the page there is a email but not protected

    And now i  have problem with the buyer becouse he want the whole emails at the page protected.

    Maybe someone can answer me at the pirvate ?

    Please help i'm not expert in writing regural expression.

     

  •  11-05-2009, 5:38 PM 57177 in reply to 57172

    Re: Mailto regex

    I suggest that you think about what you are actually trying to find here. You state in the original question that you are looking for the "mailto" items, but your pattern seems to restrict the search to only those instances that occur within the "<a>" tags and following an "href=" attribute.

    Are you looking for ANY "mailto:name@email.address" structure or are there specific places where you need to look? If the former, then take away all of the other parts of your pattern, and if the latter then tell us where to find the text.

    Susan

View as RSS news feed in XML