Solved

How to parse a string?

Posted on 2006-10-20
3
229 Views
Last Modified: 2013-12-24
In Coldfusion, I need to parse a delimited string and put it into an array and then later loop through that array.

What is the easiest way to do that?
0
Comment
Question by:futureman
3 Comments
 
LVL 12

Accepted Solution

by:
mkishline earned 25 total points
ID: 17775014
<cfset arr = ArrayNew(1) />
<cfloop index="i" list="#delimitedstring#" delimiter="character_that_serves_as_delimiter">
  <cfset ArrayAppend(arr, i) />
</cfloop>

then to loop through the array later
<cfloop index="J" from="1" to="#ArrayLen(arr)#">
  #arr[j]#
</cfloop>
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 25 total points
ID: 17775239
Use the function   "listToArray()"

 <cfset variables.myArray = listToArray(variables.myList)>

 If the list is not comma delimited, add the delimiter..

 Say the delimiter is the pipe  '|'

  <cfset variables.myArray = listToArray(variables.myList, "|")>
0
 

Author Comment

by:futureman
ID: 17775350
Thanks.   That was exactly what I was looking for.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question