Young Jedi,

Be careful with the Java split method... In your example, the length is
indeed 4... However, this:

<cfset lst = "jedi,homer,,," />
#ArrayLen(lst.split(","))#

Only has TWO array elements. It seems to only count list items until no more
valid items are found. This seems to be confirmed at the bottom of:

http://www.rgagnon.com/javadetails/java-0438.html

An interesting thing about String.split():

"  s".split(" ")     -> {"","","s"}
"".split("" )        -> {""}
" ".split(" ")       -> {} (!)
"       ".split(" ") -> {} (!)
"  s ".split(" ")    -> {"","","s"} (!) 


.......................
Ben Nadel 
www.bennadel.com

-----Original Message-----
From: JediHomer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 22, 2006 1:25 PM
To: CF-Talk
Subject: Re: What is the easiest way to get the true length of a list.

You could possibly do something like...

<cfset lst = "jedi,homer,,rocks" />
<cfoutput>#ArrayLen(lst.split(","))#</cfoutput>

Which will output 4 and not 3


HTH



On 22/08/06, Ian Skinner <[EMAIL PROTECTED]> wrote:
> Counting all the elements, including the empty ones?
>
> Do I need to modify the list to put some throwaway character to get all
the elements counted, or is there a better way?
>
> For Example:  listLen("This is an Element,,") needs to equal 3.
>
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> www.BloodSource.org
> Sacramento, CA
>
> ---------
> | 1 |   |
> ---------  Binary Soduko
> |   |   |
> ---------
>
> "C code. C code run. Run code run. Please!"
> - Cynthia Dunning
>
> Confidentiality Notice:  This message including any attachments is for 
> the sole use of the intended
> recipient(s) and may contain confidential and privileged information. 
> Any unauthorized review, use, disclosure or distribution is 
> prohibited. If you are not the intended recipient, please contact the 
> sender and delete any copies of this message.
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250624
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to