How do you parse "pipe delimited data" with coldfusion. Example..

LeadCo used Ask the Experts™
How do you parse this:

Code is setu like this:

Code that needs parsed:

I need to pull out each variable ( status, Pingid, Payout)

God bless.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
that's easy - just treat your variable as a |-delimited list and use appropriate cf list functions or cfloop over the |-delimited list to get the keys/values you need.

one thing to keep in mind: cf treats consecutive list delimiters as one delimiter!
so make sure there are no empty list elements: before you parse the list, change any || to | | (that is pipe-space-pipe) using replace() cf function.


Can you provide the code to parse the data so i may see how it works?

<cfset mylist = "Status|Rejected|PingId|4102|Payout|0">
<cfset mylist = replace(mylist, "||", "| |", "all")>
<cfloop from="1" to="#listlen(mylist, '|')#" index="x" step="2">
#listgetat(mylist, x, "|")#=#listgetat(mylist, x+1, "|")#<br />

OR, if you just want to extrace a value of a specific key from the list, say PingId key:
PingID = #listgetat(mylist, listfindnocase(mylist, "PingId", "|")+1, "|")#


Great! Are you Looking  for work?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial