House of Fusion
Search over 2,500 ColdFusion resources here
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Talk (CF-Talk)

Get the Real list len

Peter Boughton
03/29/2007 04:47 PM

There are several options: 1) Replace blank items with dummies. <cfset Text = Replace(Text,'||','| |','all')/> <cfset Text = Replace(Text,'||','| |','all')/> (You need to do it twice incase there are ajacant blanks.) 2) Use Java methods to handle it. Not sure what the Java listlen equivalent is, but Text.split('|') will convert to an array with blank items being blank items in the array, then you could do arraylen 3) Count the delimiters and add one: <cfset TheLength = 1+Len(REReplace(Text,'[^|]','','all'))/> Other people can probably suggest other methods, which is best depends on what you want to do (ie: if you /just/ want the length, or if you'll then be manipulating the data afterwards). >This list below really has 20 entries, but when I do a listlen on it, it >returns 19. It doesn't read the NULL value in the second spot >highlighted in red. I am reading a file that is generated from an >outside system, where the administrator does not want change the way it >works. > >1346||258806|19520722|F|1|2|1|21|0|20050113|1|2|2|1|2|2|3|3|99111

Search cf-talk

July 25, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference