Remove null element and dangle delimiter from a list

Hello Friends,

In out day to day programming we use list. Sometimes we are getting list with some null element and dangle delimiter so we are applying code for removing null element. Today I have done simple and easy solution for that. I hope it will be helpful for you.

[code:cf]
<cfset List1 = ‘bharat,akash,,pritesh,,nirav,6,,7,’>
<b>List1</b> : <cfoutput>#List1#</cfoutput><br />
<cfset List2 = ArrayToList(ListToArray(List1,’,’))>
<b>List2</b> : <cfoutput>#List2#</cfoutput>
[/code]
Output as per above code is
[code:html]List1 : bharat,akash,,pritesh,,nirav,6,,7,
List2 : bharat,akash,pritesh,nirav,6,7[/code]