preg_replace href 锚点与锚文本

kha*_*lil 3 php regex preg-replace

如何用每个锚文本替换所有锚。我的代码是

$body='<p>The man was <a href="http://www.example.com/video/">dancing like a little boy</a> while all kids were watching ... </p>';
Run Code Online (Sandbox Code Playgroud)

我希望结果是:

<p>The man was dancing like a little boy while all kids were watching ... </p>
Run Code Online (Sandbox Code Playgroud)

我用了 :

$body= preg_replace('#<a href="https?://(?:.+\.)?ok.co.*?>.*?</a>#i', '$1', $body);
Run Code Online (Sandbox Code Playgroud)

结果是:

<p>The man was while all kids were watching ... </p>
Run Code Online (Sandbox Code Playgroud)

Man*_*ish 5

尝试这个

$body='<p>The man was <a href="http://www.example.com/video/">dancing like a little boy</a> while all kids were watching ... </p>';

    echo preg_replace('#<a.*?>([^>]*)</a>#i', '$1', $body);
Run Code Online (Sandbox Code Playgroud)