Böyle bir şey, sizi dikkate alınarak diğer href
s ile yeniden kullanmak isteyebilirsiniz ne:
$str = '<a href="link.html">text</a>';
$result = preg_replace('#(<a[^>]*>).*?(</a>)#', '$1$2', $str);
var_dump($result);
Seni alacak olan:
string '<a href="link.html"></a>' (length=24)
(I'm considering you made a typo in the OP ? )
If you don't need to match any other href, you could use something like :
$str = '<a href="link.html">text</a>';
$result = preg_replace('#(<a href="link.html">).*?(</a>)#', '$1$2', $str);
var_dump($result);
Ayrıca alacak Hangi:
string '<a href="link.html"></a>' (length=24)
As a sidenote : for more complex HTML, don't try to use regular expressions : they work fine for this kind of simple situation, but for a real-life HTML portion, they don't really help, in general : HTML is not quite "regular" "enough" to be parsed by regexes.