Listcontains usage with opposite condition
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.
精彩评论