![](/img/trans.png)
[英]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.