you need to find and replace only the link name of all links that are in the line
If you only need a search, then you can:
$str = '<a href="link">название ссылки 1</a> <a href="link" title="подпись">название ссылки 2</a>'; preg_match_all('~<a[^>]*>(.+?)</a>~', $str, $arr); var_dump( $arr[1] );
Result:
array (size=2) 0 => string 'название ссылки 1' 1 => string 'название ссылки 2'
If search with replacement, then:
$repl = 'Новое название ссылки'; $str = preg_replace('~(<a[^>]*>).+?(</a>)~', "$1{$repl}$2", $str); var_dump( $str );
Result:
<a href="link">Новое название ссылки</a> <a href="link" title="подпись">Новое название ссылки</a>
str_replace- not suitable? - Manitikyl