Copy link to clipboard
Copied
I am trying to use listgetat but when it is passed a string that has commas in it... it screws up.
test = "this is my string,'this, is,another'";
testoutput = listgetat(test,2);
gives me 'this
Is there a way to get it to recognize the whole second string?
Copy link to clipboard
Copied
Try this:
delim = "','",
testoutput = listgetat(test,2,delim);
Copy link to clipboard
Copied
thanks for the reply, but I don't think that would work if their weren't any single quotes in the string
test = "look at this string, the second string";
using that as a delimiter would return the entire string above. (or error if you referred to the second position)
Copy link to clipboard
Copied
If you like to separate string having comma, the best method is use a different delimiter, or use combination delimiter such as ":;" (without quotes).
-Prasanth
Copy link to clipboard
Copied
I was unable to change the delimiters as this has already been implimented.
This was my fix:
<cfset stringlen = len(mystring)>
<cfset inside = 0>
<cfset newstring = "">
<cfloop from="0" to="#stringlen-1#" index="x">
<cfset thischar = arguments.docTitleList.charat(x)>
<cfif thischar eq '"' and inside eq 0>
<cfset inside = 1>
<cfset thischar = "">
<cfelseif thischar eq '"' and inside eq 1>
<cfset inside = 0>
<cfset thischar = "">
</cfif>
<cfif thischar eq "," and inside eq 1>
<cfset thischar = "|">
</cfif>
<cfset newstring = newstring&thischar>
</cfloop>