开发者

Listcontains usage with opposite condition

开发者 https://www.devze.com 2023-03-18 17:37 出处:网络
Is there a opposite operator option for the Listcontains function in coldfusion? I need to check to make a sure a value d开发者_JAVA百科oes not exist in a string but combine this with another operator

Is there a opposite operator option for the Listcontains function in coldfusion? I need to check to make a sure a value d开发者_JAVA百科oes 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") >


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

or in cfscript

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号