I want to remove inline css from string in javascript:
var str = "p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'}
span.Apple-tab-span {white-space:pre} This is sample text";
I want
str = "This is sample text";
Could you please help me how to do this?
Thanks
If your string has always this pattern: The text after a css definition, you can try this:
const str = "p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'} span.Apple-tab-span {white-space:pre} This is sample text"
const lastOccurrence = str.lastIndexOf('}')
console.log(str.substr(lastOccurrence+1, str.length))
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.