I'm having a trouble with blog posts excerpt..
I'm using Wordpress as headless CMS and it returns me post excerpt in specific format. It looks like <p>some text here [...]</p>
and I'm trying to write one regular expression that will get rid of paragraphs and those brackets with dots in between.
I ended up with something like
excerpt.replace(/<p>|<\/p>/g, '')
and it works with paragraphs but I can't find any solution to get rid of those three dots in one regular expression..
Is that possible at all?
Ok - I didn't notice one thing xD
Wordpress returns […]
instead of [...]
..
Now everything works perfectly with something like
const parsedExcerpt = excerpt.replace(/<p>|<\/p>|\r?\n|\r|\[…]/g, '');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.