Reputation: 13
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") >
Upvotes: 0
Views: 1562
Reputation: 28873
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.
Upvotes: 2
Reputation: 3382
<cfif checkstring eq 1 and not listcontains( idcheck, 'id1' )>
or in cfscript
if ( checkstring == 1 && !listcontains( idcheck, 'id1' ) )
Upvotes: 2