Another idea is to use regular expressions like so:

<cfset list1="a,b,c,d,e">
<cfset list2="c,e">

<cfloop list="#List2#" index="i">
<cfset List1=REReplace(List1,"(#i#,)|(,#i#)$","","All")>
</cfloop>

List1 will now contain "a,b,d"

In case you are unfamiliar with Regex's, for the first time through the loop, #i# will 
be "c" and the RegEx will be:

(c,)|(,c)$

This will match "c" followed by a comma, OR comma followed by a C only when it's the 
last item in the string.  Hence, this should remove all occurances of C from the list.

The description of RegEx in the CFDOCS is quite good.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to