regex (in PHP) to match & that aren't HTML entities

后端 未结 5 1595
说谎
说谎 2020-12-17 05:01

Here\'s the goal: to replace all standalone ampersands with & but NOT replace those that are already part of an HTML entity such as  .

I think I nee

5条回答
  •  温柔的废话
    2020-12-17 05:32

    You could always run html_entity_decode before you run htmlentities? Works unless you only want to do ampersands (and even then you can play with the charset parameters).

    Much easier and faster than a regex.

提交回复
热议问题