Solved

How to parse a string?

Posted on 2006-10-20
3
230 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 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.htacess file 301 redirects that are strange 4 71
AWS New EC2 Instance and EBS Storage 2 95
cookies analysis tools 2 106
Redirect to HTTPS results in Infinite LOOP 4 151
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
What You Need to Know when Searching for a Webhost Provider
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. 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 :…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

733 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