Remove links for anchor tag <a href=\"/default/imp/compose.php?to=user1%40lakhi.com\"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lakhi
    New Member
    • Oct 2006
    • 5

    #1

    Remove links for anchor tag <a href=\"/default/imp/compose.php?to=user1%40lakhi.com\"

    Hi ,

    I want to remove the anchor tag only if the anchor value is Email

    the follwoing is source.

    Code:
    $text = "Forwarded message from <a href=\"/default/imp/compose.php?to=emsroot%40bdcarchive.in\" title=\"New Message emsroot@bdcarchive.in\">emsroot@bdcarchive.in</a><br>
    &nbsp;Subject: test message<br />
    &nbsp; &nbsp; &nbsp; To: <a href=\"/default/imp/compose.php?to=user1%40lakhi.com\" title=\"New Message to user1@lakhi.com\"> user1@lakhi.com </a><br />
    &nbsp; &nbsp; &nbsp; Cc: <a href=\"/default/imp/compose.php?to=user2%40lakhi.com\" title=\"New Message to user2@lakhi.com\"> user2@lakhi.com </a><br />
    &nbsp; &nbsp; &nbsp; BCC: <a href=\"/default/imp/compose.php?to=user2%40lakhi.com\" title=\"New Message to user.user3@lakhi.com\"> user3@lakhi.com </a><br />" ;

    where ever the email with link,i want to display only email with our link.

    Any suggetion or help would be appreciate.

    Thanks inadvance
    Last edited by Dormilich; Aug 4 '10, 08:59 PM. Reason: Please use [code] tags when posting code
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Take a look at preg_match and preg_replace.

    Find a regex online that suffices for your links, many any tweaks as necessary.


    Dan

    Comment

    • Lakhi
      New Member
      • Oct 2006
      • 5

      #3
      am very new to PHP,basically java developer,no idea how to use these in php

      Comment

      • Lakhi
        New Member
        • Oct 2006
        • 5

        #4
        i have this regexp <a href=[^>]* title=[^>]*>

        which will find anchor tag <a href=\"/default/imp/compose.php?to= user1%40lakhi.c om\" title=\"New Message to user1@lakhi.com\">

        Comment

        • dlite922
          Recognized Expert Top Contributor
          • Dec 2007
          • 1586

          #5
          The manual should help you understand how to use them:

          Perform a regular expression search and replace



          Dan

          Comment

          Working...