[英]How to replace double quotes with single quotes inside of a string using regex?
[英]Replace single quotes with double quotes in tags only! Using ColdFusion regex
我只看到針對此問題的PHP解決方案。
基本上我需要從:
<TEXTFORMAT LEADING='2'><P ALIGN='LEFT'><FONT FACE='Verdana' style='font-size:10' COLOR='#0B333C'>My name's Mark</FONT></P></TEXTFORMAT>
對此:
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C">My name's Mark</FONT></P></TEXTFORMAT>
使用ReReplaceNoCase但是...是的,您猜對了..我很討厭正則表達式! :)
在這種情況下,您可以通過XML解析庫讓CF為您完成工作,而不需要使用正則表達式:
<cfsavecontent variable = "origStr">
<cfoutput>
<TEXTFORMAT LEADING='2'><P ALIGN='LEFT'><FONT FACE='Verdana' style='font-size:10' COLOR='##0B333C'>My name's Mark</FONT></P></TEXTFORMAT>
</cfoutput>
</cfsavecontent>
<cfset xmlString = ToString(xmlParse(origStr))>
<cfdump var="#xmlString#">
哪個會回來:
<?xml version="1.0" encoding="UTF-8"?> <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT COLOR="#0B333C" FACE="Verdana" style="font-size:10">My name's Mark</FONT></P></TEXTFORMAT>
如果那個領先的<?xml...>
惹惱了您,則可以刪除該部分:
<cfdump var="#Right(xmlString, Len(xmlString) - 40)#">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.