At 06:43 PM 10/10/2009, you wrote: >>>><cfset thelist ="aa,bb,cc,dd,ee,ff,uu,vv,ww,xx,yy,zz"> >> >>What would be the most efficient way to split the list into two lists, >> >>Try this : >><cfset thelist ="aa,bb,cc,dd,ee,ff,uu,vv,ww,xx,yy,zz"> >><CFSET st = REFind ("([^\,]*\,){6}", thelist, 1, true)> >><CFSET list1 = mid(theList, 1, st.len[1]-1)> >><CFSET list2 = mid(theList, st.len[1]+1, 9999)> >><CFOUTPUT> >>list1 = #list1#<BR> >>list2 = #list2#<BR> >></CFOUTPUT> > > >I've been looking for this for long now. >What happens when you have a list containing coma-delimited numbers, say > >"1,2,3,4,....X" > >Where "X" is a number below 5000. >How do you split this list into equal lengths of 100?
This is an overly simple, inelligant, and inefficient method, but works nevertheless (in about a second). <cfoutput>#now()#</cfoutput> <!--- making the list ---> <cfset thelist =""> <cfloop from="1" to="5000" index="hoohah"> <cfset thelist = listAppend(thelist,hoohah)> </cfloop> <!--- making and appending the sublists ---> <cfset counter=1> <cfset lists = ArrayNew(1)> <cfset lists[counter] = ""> <cfloop from="1" to="#listLen(thelist)#" index="ii"> <cfset lists[counter] = listappend(lists[counter],ii)> <cfif ii / 100 eq round( ii / 100 ) and ii neq listLen(thelist)> <cfset counter = counter + 1> <cfset lists[counter] = ""> </cfif> </cfloop> <!--- displaying the sublists ---> <cfoutput> <cfloop from="1" to="#arrayLen(lists)#" index="current"> <li><strong>lists[#current#]</strong> = #lists[current]#</li> </cfloop> </cfoutput> <cfoutput>#now()#</cfoutput> This could easily be turned into a UDF with the 100 being an argument. Another way would be to whip through the original list character by character, counting the placement of commas at every hundredth mark and do a mid() each time. Mik -------- Michael Muller Admin, MontagueMA.net Website ...a project of MontagueWebWorks.com mobile (413) 320-5336 http://www.MontagueMA.net Eschew Obfuscation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327109 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4