我有以下字符串:
var string = "<p>How well does Angular Work? We’re about to see!
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vehicula
imperdiet sapien, placerat vulputate sem bibendum id. In hac habitasse
platea dictumst. Nulla enim lectus, laoreet non posuere at, ultricies id
leo. Nullam nec eros lacus. Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Integer egestas scelerisque […]</p> "
我使用以下正则表达式过滤器:
string.replace(/<\/?[^>]+>/gi, '');
然后我得到:
How well does Angular Work? We’re about to see! Lorem ipsum dolor
sit amet, consectetur adipiscing elit. Aliquam vehicula imperdiet sapien,
placerat vulputate sem bibendum id. In hac habitasse platea dictumst. Nulla
enim lectus, laoreet non posuere at, ultricies id leo. Nullam nec eros
lacus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer
egestas scelerisque […]
正如您所看到的,“我们”中的撇号返回’
而[…]
位于字符串的末尾而不是[...]。我从Wordpress得到这个字符串,我想把它放在我自己的html页面中。当过滤器完成后,我应该得到:
How well does Angular Work? We're about to see! Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Aliquam vehicula imperdiet sapien, placerat
vulputate sem bibendum id. In hac habitasse platea dictumst. Nulla enim
lectus, laoreet non posuere at, ultricies id leo. Nullam nec eros lacus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer egestas
scelerisque. . .