i need to remove spaces just between quotation marks and just after style properties with regexp.
before:
<h2><span style="font-family: Georgia; font-size: 10pt;">Text</span></h2>
after:
<h2><span style="font-family:Georgia; font-size:10pt;">Text</span></h2>
It's important for me because i need to convert html code to rtf file. Thanks for help
捕获包含空间的组的正则表达式如下所示:
".+?:(\s{1}).+?;"?
If you want remove inside the style attribute you can use the following code
m = data.replace(/style="(.+?)"/,($1)=>{
return $1.replace(/(?<=:)\s(?=\w)/g,'')
});
If you want replace anywhere in the string use following one
m = data.replace(/(?:(?<=:)\s(?=\w)|(?<=;)\s)/g,'')
This may help you :
(:\s)(?=(?:(?:[^"]*"){2})*[^"]*"[^"]*$)
It will capture all ": " (colon followed by a whitespace) that are between two " (doublequotes). Then you could replace them by a single colon, that should do what you wish.
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.