Maison  >  Article  >  développement back-end  >  javascript - 用js,替换一段字符串当中以background-color: rgb为开头,

javascript - 用js,替换一段字符串当中以background-color: rgb为开头,

WBOY
WBOYoriginal
2016-06-06 20:11:211256parcourir

用js,替换一段字符串当中以background-color: rgb为开头,以;结尾的字符串,替换为background-color: rgb(225,23,45);

回复内容:

用js,替换一段字符串当中以background-color: rgb为开头,以;结尾的字符串,替换为background-color: rgb(225,23,45);

<code>"background-color: rgb(afdf);".replace(/\b(background-color:\s*rgb)[^;\n]*;/g,"$1(255,23,45);")</code>
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn