0

/t5/coldfusion-discussions/multiple-chr-delimiters/td-p/509049
Jun 19, 2006
Jun 19, 2006
Copy link to clipboard
Copied
Is there a way to use multiple characters as a delimiter? For
instance:
<cfloop index="i" list="1 : 2 : 3 : 4" delimiters=" : "></cfloop>
If not -- how would you do this. We have data comming from a third party and it has some inconsistent data. If we can use multiple delimiters then it will solve the problem.
<cfloop index="i" list="1 : 2 : 3 : 4" delimiters=" : "></cfloop>
If not -- how would you do this. We have data comming from a third party and it has some inconsistent data. If we can use multiple delimiters then it will solve the problem.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Jun 19, 2006
Jun 19, 2006
Thanks everyone -- got it!
Mentor
,
/t5/coldfusion-discussions/multiple-chr-delimiters/m-p/509050#M46400
Jun 19, 2006
Jun 19, 2006
Copy link to clipboard
Copied
Per live docs at
cfloop:
looping over a list or file
You can put more than one character in the delimiters attribute, in any order. For example, this loop processes commas, colons, and slashes as list delimiters:
<cfloop index = "ListElement"
list = "John/Paul,George::Ringo"
delimiters = ",:/">
<cfoutput>#ListElement#</cfoutput><br>
</cfloop>
Phil
You can put more than one character in the delimiters attribute, in any order. For example, this loop processes commas, colons, and slashes as list delimiters:
<cfloop index = "ListElement"
list = "John/Paul,George::Ringo"
delimiters = ",:/">
<cfoutput>#ListElement#</cfoutput><br>
</cfloop>
Phil
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/coldfusion-discussions/multiple-chr-delimiters/m-p/509052#M46402
Jun 19, 2006
Jun 19, 2006
Copy link to clipboard
Copied
What if you need the delimiter to be " : "? Here is an
example of the data we are dealing with:
Cards: US : Paper : Trash
"Cards: US is the first item. Not Cards and then US. There are only 3 items in this list NOT 4. If we use ":" as the delimiter it would appear to be 4 different items.
Cards: US : Paper : Trash
"Cards: US is the first item. Not Cards and then US. There are only 3 items in this list NOT 4. If we use ":" as the delimiter it would appear to be 4 different items.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/multiple-chr-delimiters/m-p/509053#M46403
Jun 19, 2006
Jun 19, 2006
Copy link to clipboard
Copied
You may want to use a different separator then, because a
delimiter is a single character. You can define multiple delimiters
for the command to look for, but the delimiter still has to be a
single character.
We usually use the pipe (|) because it is a non-standard character that you won't find cropping up in everyday strings, like colons or commas do.
We usually use the pipe (|) because it is a non-standard character that you won't find cropping up in everyday strings, like colons or commas do.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/multiple-chr-delimiters/m-p/509051#M46401
Jun 19, 2006
Jun 19, 2006
Copy link to clipboard
Copied
>
You can put more than one character in the delimiters attribute,
in any
> order. For example, this loop processes commas, colons, and slashes as list
> delimiters:
I didn't take the requirement to mean "more than one delimiter", but to be
"one multi-character delimiter"..?
CF does not support multi-character delimiters natively. You can use the
Java split() method to split your list into an array, and then loop over
the array.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#split(java.lang.String)
--
Adam
> order. For example, this loop processes commas, colons, and slashes as list
> delimiters:
I didn't take the requirement to mean "more than one delimiter", but to be
"one multi-character delimiter"..?
CF does not support multi-character delimiters natively. You can use the
Java split() method to split your list into an array, and then loop over
the array.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#split(java.lang.String)
--
Adam
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/multiple-chr-delimiters/m-p/509054#M46404
Jun 19, 2006
Jun 19, 2006
Copy link to clipboard
Copied
<cfscript>
theList="1 : 2 : 3 : 4 : 5 : test:meElmo : duck:and:cover";
mcRegex="\s:\s";
pattern=createObject("java","java.util.regex.Pattern").compile(mcRegex);
parsedArray=pattern.split(theList);
</cfscript>
<cfdump var="#parsedArray#">
theList="1 : 2 : 3 : 4 : 5 : test:meElmo : duck:and:cover";
mcRegex="\s:\s";
pattern=createObject("java","java.util.regex.Pattern").compile(mcRegex);
parsedArray=pattern.split(theList);
</cfscript>
<cfdump var="#parsedArray#">
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/coldfusion-discussions/multiple-chr-delimiters/m-p/509055#M46405
Jun 19, 2006
Jun 19, 2006
Copy link to clipboard
Copied
Thanks everyone -- got it!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

