Regex in Javascript to remove links

后端 未结 6 1727
南旧
南旧 2020-12-06 17:22

I have a string in JavaScript and it includes an a tag with an href. I want to remove all links and the text. I know how to just r

6条回答
  •  一向
    一向 (楼主)
    2020-12-06 17:45

    Regexes are fundamentally bad at parsing HTML (see Can you provide some examples of why it is hard to parse XML and HTML with a regex? for why). What you need is an HTML parser. See Can you provide an example of parsing HTML with your favorite parser? for examples using a variety of parsers.

提交回复
热议问题