简体   繁体   中英

javascript replace with regexp

I have a string that contains a lot of

<span style="font-size:8px;">...</span> 
<span style="font-size:14px;"> ...</span>

And i want to replace all font-size values to given value. So i need a regexp to replace all chars beetween "font-size:" and "px;"

Ps i use Rangy JS library

var iframe = $('iframe')[0];
            var sel =  rangy.getIframeSelection(iframe);
            selected_html=sel.toHtml();
            selected_html.replace("font-size:<some regexp>px;", "36");

Can you suggest a proper regexp?

.replace(/(font-size:)\d+(px;)/g, "$1"+36+"$2");

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM