简体   繁体   English

正则表达式删除 HTML 标签和 \r 和 \n 标签

[英]Regex expression to remove HTML tags And \r and \n tags

I have a strings like我有一个字符串

'{\"name\":\"[\\\"Uses\\\",\\\"Tags\\\"]\",\"value\":\"[\\\"<table border=\\\\\\\"0\\\\\\\" cellpadding=\\\\\\\"0\\\\\\\" cellspacing=\\\\\\\"0\\\\\\\" width=\\\\\\\"299\\\\\\\" xss=removed><tbody><tr height=\\\\\\\"60\\\\\\\" xss=removed>\\\\r\\\\n  <td height=\\\\\\\"60\\\\\\\" class=\\\\\\\"xl66\\\\\\\" width=\\\\\\\"299\\\\\\\" xss=removed>A\\\\r\\\\n  cleaning product, A repair service, A fashion brand, A personal shopper, An\\\\r\\\\n  app,<\\\\\\/td><\\\\\\/tr><\\\\\\/tbody><\\\\\\/table>\\\",\\\"<table border=\\\\\\\"0\\\\\\\" cellpadding=\\\\\\\"0\\\\\\\" cellspacing=\\\\\\\"0\\\\\\\" width=\\\\\\\"232\\\\\\\" xss=removed><tbody><tr height=\\\\\\\"60\\\\\\\" xss=removed>\\\\r\\\\n  <td height=\\\\\\\"60\\\\\\\" class=\\\\\\\"xl66\\\\\\\" width=\\\\\\\"232\\\\\\\" xss=removed>Apparel,\\\\r\\\\n  Charity & Nonprofit , Fashion, Operations, Products, Retail &\\\\r\\\\n  eCommerce<\\\\\\/td><\\\\\\/tr><\\\\\\/tbody><\\\\\\/table>\\\"]\"}'

I want to remove html tags.我想删除 html 标签。 I tried:我试过了:

<[^>]*>|\\|(u00a0*.)

It removes most of it but它删除了大部分但

\\r\\\\n

still remains.仍然存在。 please help me out.请帮帮我。

var string = '{\"name\":\"[\\\"Uses\\\",\\\"Tags\\\"]\",\"value\":\"[\\\"<table border=\\\\\\\"0\\\\\\\" cellpadding=\\\\\\\"0\\\\\\\" cellspacing=\\\\\\\"0\\\\\\\" width=\\\\\\\"299\\\\\\\" xss=removed><tbody><tr height=\\\\\\\"60\\\\\\\" xss=removed>\\\\r\\\\n  <td height=\\\\\\\"60\\\\\\\" class=\\\\\\\"xl66\\\\\\\" width=\\\\\\\"299\\\\\\\" xss=removed>A\\\\r\\\\n  cleaning product, A repair service, A fashion brand, A personal shopper, An\\\\r\\\\n  app,<\\\\\\/td><\\\\\\/tr><\\\\\\/tbody><\\\\\\/table>\\\",\\\"<table border=\\\\\\\"0\\\\\\\" cellpadding=\\\\\\\"0\\\\\\\" cellspacing=\\\\\\\"0\\\\\\\" width=\\\\\\\"232\\\\\\\" xss=removed><tbody><tr height=\\\\\\\"60\\\\\\\" xss=removed>\\\\r\\\\n  <td height=\\\\\\\"60\\\\\\\" class=\\\\\\\"xl66\\\\\\\" width=\\\\\\\"232\\\\\\\" xss=removed>Apparel,\\\\r\\\\n  Charity & Nonprofit , Fashion, Operations, Products, Retail &\\\\r\\\\n  eCommerce<\\\\\\/td><\\\\\\/tr><\\\\\\/tbody><\\\\\\/table>\\\"]\"}'
string = string.replace(/(<([^>]+)>)|\\r|\\n/ig,"")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM