sastro Posted January 24, 2010 Share Posted January 24, 2010 Hi all, i have string <div align="center"> <p><a class=lns href="../index-2.html">etourism </a>|<a class=lns href="places.html"> Destination</a> | <a class=lns href="restaurant.html">Restaurant</a> |<a class=lns href="travel.html"> Travel-agent</a> | <a class=lns href="money.html">Money-changer </a> |<a class=lns href="shop.html"> Artshop</a> | <a class=lns href="history.html">History</a> | <a class=lns href="map/index.html">Map</a><br> <A class=lns href="../general/say.html">Say in Indonesia</A> | <A class=lns href="../general/dont.html">Do & Don'ts </A>|<A class=lns href="../general/health.html"> Tropical Health </A> | <A class=lns href="../general/essntl.html">Essential</A> |<A class=lns href="../general/fact.html"> Fast-fact</A> | <A class=lns href="../general/formal.html">Travel Formality</A> | <A class=lns href="mailto:webmaster@etourism.com">Webmaster</A> |<A class=lns href="../general/term.html"> Term of Use</A> </p> </div> </div> how to remove using preg_replace only for link and anchor text <A class=lns href="mailto:webmaster@etourism.com">Webmaster</A> | I'm using preg_replace('/<A class=lns(.*)webmaster@etourism.com(.*)\|/i','',$str); but not work Quote Link to comment https://forums.phpfreaks.com/topic/189622-replace-link/ Share on other sites More sharing options...
.josh Posted January 24, 2010 Share Posted January 24, 2010 Your problem is your stars are greedy. change .* to .*? though personally I'd probably suggest using a negative char class instead: [^|]* Also since you are replacing it with nothing, no reason to capture anything in there (get rid of the parenthesis) Also judging by your example, you may need to add the s modifier to your pattern. Quote Link to comment https://forums.phpfreaks.com/topic/189622-replace-link/#findComment-1000898 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.