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

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

WBOY
WBOYOriginal
2016-06-06 20:11:211255browse

用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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn