Listcontains usage with opposite condition

为君一笑 提交于 2019-12-25 01:23:05

问题


Is there a opposite operator option for the Listcontains function in coldfusion? I need to check to make a sure a value does not exist in a string but combine this with another operator.

Sort of like this:

   <cfif checkstring EQ 1 and does not contain listcontains(idcheck,"id1") >

回答1:


<cfif checkstring eq 1 and not listcontains( idcheck, 'id1' )>

or in cfscript

if ( checkstring == 1 && !listcontains( idcheck, 'id1' ) )




回答2:


I would probably prefer using NOT, as Charlie showed. But since listContains returns an index, you could also use

<cfif checkstring EQ 1 and listcontains(idcheck, "id1") eq 0>

But I would mention listContains() performs partial matches. So "id1" would match not only "id1" but "id111" and "id1001" as well. Is that really the comparison you want? If you want to find exact matches only, use ListFind() or ListFindNoCase() instead.



来源:https://stackoverflow.com/questions/6587803/listcontains-usage-with-opposite-condition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!