Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to parse a string?

Posted on 2006-10-20
3
Medium Priority
?
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
mkishline earned 100 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 100 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
What You Need to Know when Searching for a Webhost Provider
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

618 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