Regex / DOMDocument - match and replace text not in a link

后端 未结 7 1123
轮回少年
轮回少年 2020-12-01 07:06

I need to find and replace all text matches in a case insensitive way, unless the text is within an anchor tag - for example:

Match this text and re

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 07:49

    Match this text and replace it

    Don\'t match this text

    We still need to match this text and replace it

    '; $res = preg_replace("#[^]match this text#",'replacement',$a); echo $res; ?>

    This way works. Hope you want realy case sensitive, so match with small letter.

提交回复
热议问题