Remove/Replace-href/anchor/link-in html/string-pregu Replace-php-regex-regular表达式

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Remove/Replace-href/anchor/link-in html/string-pregu Replace-php-regex-regular表达式相关的知识,希望对你有一定的参考价值。

Replaces all links within href part of anchor in a html-String.
  1. /*
  2.  * DO NOT USE THE PATTERN STRING DIRECTLY IN 'preg_match()' !!!!
  3.  *
  4.  */
  5. $pattern = '/(?<=href=")[^]]+?(?=")/';
  6. $replacedHrefHtml = preg_replace($pattern, $replacement, $html);

以上是关于Remove/Replace-href/anchor/link-in html/string-pregu Replace-php-regex-regular表达式的主要内容,如果未能解决你的问题,请参考以下文章