更新:以及我認爲這個問題更簡單。如果你想看到我的原始答案,只需看看這篇文章的編輯歷史。這個答案使用了類似的原則,儘管你在那裏搜索一個你不想刪除的項目,然後用replace替換它。
<cfset teststr1 = "font-family: BebasNeue;" />
<cfset teststr2 = "font-family: Verdana" />
<cfset teststr3 = "font-family: BebasNeue; font-family: Times New Roman; color: red" />
<cfset search1 = "(font-family:\s*)((BebasNeue)|[\w ]+)(;)?" />
<cfset replace1 = "font-family: \3swiss7\4" />
<cfset search2 = "BebasNeueswiss7" />
<cfset replace2 = "BebasNeue" />
<cfoutput>
<ol>
<li>#replaceNoCase(reReplaceNoCase(teststr1, search1, replace1, "all"), search2, replace2, "all")#</li>
<li>#replaceNoCase(reReplaceNoCase(teststr2, search1, replace1, "all"), search2, replace2, "all")#</li>
<li>#replaceNoCase(reReplaceNoCase(teststr3, search1, replace1, "all"), search2, replace2, "all")#</li>
</ol>
</cfoutput>
結果:
1. font-family: BebasNeue;
2. font-family: swiss7
3. font-family: BebasNeue; font-family: swiss7; color: red
所以基本上你替換與所選擇的字體類型的所有字體系列,在這種情況下swiss7,但通過在更換小組選擇你離開BebasNeue中的字體串。然後再執行一個步驟清理留下的組合字體名稱。
你到目前爲止嘗試過什麼?你得到了什麼樣的結果?你在使用什麼版本的ColdFusion?你可以把CSS放到一個單獨的文件中嗎?等 –