我'我得到Invalid list index 2
这意味着index 2
中没有定义。如何检查ColdFusion中是否定义了index 2
?
<cfif
ListGetAt('/pages.cfm/about-us/' 1 , "/") eq 'news' AND
ListGetAt('/pages.cfm/about-us/', 2 , "/") eq 'press' AND
ListGetAt('/pages.cfm/about-us/', 3 , "/") eq '2016'AND
ListGetAt('/pages.cfm/about-us/', 4 , "/") neq ''>
<cfoutput>It Works!</cfoutput>
</cfif>
答案 0 :(得分:0)
嘿,伙计们现在正在工作。
<cfif
ListLen('/pages.cfm/about-us/', "/") neq '' AND
ListGetAt('/pages.cfm/about-us/', 1 , "/") eq 'news' AND
ListLen('/pages.cfm/about-us/', "/") neq '' AND
ListGetAt('/pages.cfm/about-us/', 2 , "/") eq 'press' AND
ListLen('/pages.cfm/about-us/', "/") neq '' AND
ListGetAt('/pages.cfm/about-us/', 3 , "/") eq '2016'AND
ListLen('/pages.cfm/about-us/', "/") neq '' AND
ListGetAt('/pages.cfm/about-us/', 4 , "/") neq ''>
<cfoutput>It Works!</cfoutput>
</cfif>
答案 1 :(得分:0)
如果目标是验证文本以特定模式开头,即&#34; / news / press / 2016 / {moreChars} /&#34;,则使用正则表达式会更简单:
<cfif REFindNoCase("^/news/press/2016/[^/]+/", theStringToSearch)>
found
</cfif>