Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
preg_replace (syntax between two word not match then replace or url syntax not match
12-07-2014, 07:31 AM
Post: #1
preg_replace (syntax between two word not match then replace or url syntax not match
PHP Code:
$string '<a href="https://www.uptime.com/v/_JM?version=3" />PLAY</a></div>
<a href="https://newtime.uptime.com/v/_JM?version=3" />LINK@</a></div>
<div class="class"><a href="https:[email protected]/jdhdd.html" />LINKUP</a></div>
<a href="https://subdomain.uptime.com/v/_@%ljdmmcc=3" />subd</a></div>
<a href="https://www.cng.com/v/_JM?dkkkk#3" />GETUp</a></div>
'

remove Link except *.uptime.com*
HOw Can Get Result From String (OUTPUT)


Code:
<a href="https://www.uptime.com/v/_JM?version=3" />PLAY</a></div>
<a href="https://newtime.uptime.com/v/_JM?version=3" />LINK@</a></div>
<div class="class"></div>
<a href="https://subdomain.uptime.com/v/_@%ljdmmcc=3" />subd</a></div>
</div>

[Image: 728x90.gif]
Find all posts by this user
Like Post Quote this message in a reply
12-07-2014, 05:14 PM (This post was last modified: 12-07-2014 05:16 PM by ionutvmi.)
Post: #2
RE: preg_replace (syntax between two word not match then replace or url syntax not match
you can achieve that by using a negative lookbehind.

here is a really simple example:
Code:
https?:\/\/([a-zA-Z0-9]+\.(?!uptime))[^"]+

Using this idea you should be able to select all the link tags and that don't have uptime in them and remove them from your string.
Find all posts by this user
Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)