Coldfusion 为单个字符串多次替换NoCase
我有一个字符串,它根据查看它的人而变化。我想做的是找到关键词,并根据这些关键词改变他们说的话 为了解决这个问题,我试图在字符串上多次使用Coldfusion 为单个字符串多次替换NoCase,coldfusion,Coldfusion,我有一个字符串,它根据查看它的人而变化。我想做的是找到关键词,并根据这些关键词改变他们说的话 为了解决这个问题,我试图在字符串上多次使用ReplaceNoCase但似乎无法工作 这是我的代码: <cfset ques = Replacenocase(fullresults.question, '##clientbrand##', customTags.clientbrandname,"ALL")> <cfset ques = Replacenocase(fullresults.
ReplaceNoCase
但似乎无法工作
这是我的代码:
<cfset ques = Replacenocase(fullresults.question, '##clientbrand##', customTags.clientbrandname,"ALL")>
<cfset ques = Replacenocase(fullresults.question, '##LocationName##', customTags.locationName,"ALL")>
<cfset ques = Replacenocase(fullresults.question, '##LocationGroup##', customTags.DoctorGroupName,"ALL")>
<cfset ques = Replacenocase(fullresults.question, '##ServiceProvider##', customTags.specialist,"ALL")>
<cfset ques = Replacenocase(fullresults.question, '##SalesContact##', customTags.salesperson,"ALL")>
<cfset ques = Replacenocase(fullresults.question, '##Product_Procedure##', customTags.procedurename,"ALL")>
当我的字符串中包含#clientBrand#以及上面的代码时,它只会显示“#clientBrand#”,当我只尝试一次ReplaceNoCase时,它会显示正确的结果
我的代码有什么问题吗?有没有其他方法来替换多个变量?我刚刚意识到,每次我在做替换用例时,我都在将
ques
重置为原始形式
<cfset ques = Replacenocase(fullresults.question, '##clientbrand##', customTags.clientbrandname,"ALL")>
<cfset ques = Replacenocase(ques , '##LocationName##', customTags.locationName,"ALL")>
<cfset ques = Replacenocase(ques , '##LocationGroup##', customTags.DoctorGroupName,"ALL")>
<cfset ques = Replacenocase(ques , '##ServiceProvider##', customTags.specialist,"ALL")>
<cfset ques = Replacenocase(ques , '##SalesContact##', customTags.salesperson,"ALL")>
<cfset ques = Replacenocase(ques , '##Product_Procedure##', customTags.procedurename,"ALL")>
注意:如果任何后面的字符串中出现逗号,可能需要进行一些额外的工作
<cfset before="##clientbrand##,##LocationName##,##LocationGroup##,##ServiceProvider##,##SalesContact##,##Product_Procedure##">
<cfset after = "#customTags.clientbrandname#,#customTags.locationName#,#customTags.DoctorGroupName#,#customTags.specialist#,#customTags.specialist#,#customTags.salesperson#,#customTags.procedurename#">
<cfset ques = ReplaceList(fullresults.question, before, after)>
我发现了我的错误。Mods请关闭。您是否考虑过使用replacelist()
?我可以试试。谢谢