Strip HTML from Text JavaScript

前端 未结 30 3595
北荒
北荒 2020-11-21 05:08

Is there an easy way to take a string of html in JavaScript and strip out the html?

30条回答
  •  长情又很酷
    2020-11-21 05:33

    I have created a working regular expression myself:

    str=str.replace(/(<\?[a-z]*(\s[^>]*)?\?(>|$)||]*?(>|$)||$)|<[a-z?!\/]([a-z0-9_:.])*(\s[^>]*)?(>|$))/gi, ''); 
    

提交回复
热议问题