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

How do you parse this:

Code is setu like this:
Var1|Value1|Var2|Value2|Var3|Value3

Code that needs parsed:
Status|Rejected|PingId|4102|Payout|0

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

God bless.
LeadCoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

azadisaryevCommented:
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.
0
LeadCoAuthor Commented:
Can you provide the code to parse the data so i may see how it works?
0
azadisaryevCommented:
Example:

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

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LeadCoAuthor Commented:
Great! Are you Looking  for work? leadco@bellsouth.net
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.