Reputation: 191
I'm trying to remove all occurrences of <SPAN>
and </SPAN>
from a given text.
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>', ' ');
}
});
Upvotes: 0
Views: 146
Reputation: 6764
For removing span with content:
String(text).replace(/<span>.*<\/span>/,'');
or if you want to leave content:
String(text).replace(/<span>([^<]+)<\/span>/g,'$1');
Upvotes: 3
Reputation: 1038890
You could chain a couple more replaces to remove the starting and ending tag:
return String(text)
.replace('</span><span>', ' ')
.replace('<span>', '')
.replace('</span>', '');
Upvotes: 0