[英]How to delete all SPANs?
I'm trying to remove all occurrences of <SPAN>
and </SPAN>
from a given text. 我正在尝试从给定文本中删除所有出现的
<SPAN>
和</SPAN>
。
For example: 例如:
<span>Пн - Пт: 09:00-18:00</span><span>Сб: 09:00-13:00</span><span>Вс: выходной</span>
Here's what I've tried so far: 到目前为止,这是我尝试过的方法:
phonecatControllers.filter('htmlToPlaintext1', function() {
return function(text) {
return String(text).replace('</span><span>', ' ');
}
});
For removing span with content: 要删除内容的跨度:
String(text).replace(/<span>.*<\/span>/,'');
or if you want to leave content: 或者,如果您想离开内容:
String(text).replace(/<span>([^<]+)<\/span>/g,'$1');
You could chain a couple more replaces to remove the starting and ending tag: 您可以链接多个替换项以删除开始和结束标记:
return String(text)
.replace('</span><span>', ' ')
.replace('<span>', '')
.replace('</span>', '');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.