Treating 'OAT' as a deimiter isn't going to get you what you want.

The delimiter is not considered part of the list element itself.

So if you have "GOAT,BOAT,MOAT,BOOBS", and you want to delimit on the string
'OAT', if you're successful then you'd end up with:

G,B,M,BOOBS

... because the delimiter that you specified (OAT) is now defined as just
that... a delimiter that's not going to be returned with the list element.

I suppose you could output the loop index and concatenate an "OAT" onto it.
 But that's assuming the business rule that you're looking to satisfy is
that the word *ends* with OAT.  Originally you said "contains".  So what if
it's "Goats", plural?


So... you've got working code that currently loops over the list, and does a
conditional check for each iteration.  You're looking for a "better" way.

"Better" is subjective.  Unless you're encountering performance issues that
you can attribute to your loop and the subsequent conditional... what would
be "better"?  Doing it in one line?  Is that better?  If another developer
has to work on this code, would he or she easily understand what the code
does?

For me, part of "better" is legible code.  You described a need.  I need to
loop over this list, and if the list element contains "OAT", show it.  The
loop/conditional code is almost a literal translation of that need.  Anyone
should be able to easily maintain that code.

You can get into some ninja regular expression mindset and probably do what
you're looking to do.  But in the end... what does it buy you?  Is the code
more performant?  Is it easier to read?

Just my $0.02 :)

On Fri, Feb 12, 2010 at 11:54 AM, Paul Alkema
<paulalkemadesi...@gmail.com>wrote:

>
> Hey Aaron, Thanks for the information. Very helpful. :)
>
> Paul
>
>
> -----Original Message-----
> From: Aaron Neff [mailto:w...@itisdesign.com]
> Sent: Friday, February 12, 2010 1:05 PM
> To: cf-talk
> Subject: Re: Cfloop List Multiple Charecter Delimiters
>
>
> Hi Paul,
>
> Just fyi, CF9 added a 4th parameter (boolean "multiCharacterDelimiter") to
> the listToArray function:
>
> <cfloop array="#listToArray(variables.myList, 'oat', false, true)#"
> index="i">
>
> You have a few options!
>
> HTH,
> -Aaron
>
> I have a list that I'm trying to loop, I was wondering if it was possible
> to
> >have multiple character delimiter.
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:330671
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to