Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create string with single quotes

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am new to ColdFusion and am having trouble building a string that contains single quotes. I need a variable that looks like this:<br><br>'itema','itemb','itemc'<br><br>I already have a variable that looks like this:<br><br>itema,itemb,itemc<br><br>Can someone help?
 
Hi,<br><br>Why dont you loop on your current list and modify each item to add those single quotes?<br>A bit like this:<br>&lt;CFLOOP LIST=&quot;#yourCurrentList#&quot; INDEX=&quot;item&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;CFSET temp = &quot;'&quot; & #item# & &quot;'&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;CFSET position = ListFind(yourCurrentList, item)&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;CFSET yourCurrentList = ListSetAt(yourCurrentList, temp, position)&gt;<br>&lt;/CFLOOP&gt;<br><br>This code wont probably work directly...&nbsp;&nbsp;Edit it.&nbsp;&nbsp;I just wanted to show you the idea behind it...<br>Dont hesitate to contact me for further questions...<br><br>Thx,<br>Christian Dionne
 
<FONT FACE=monospace><b>&lt;CFSET myList=&quot;itema,itemb,itemc&quot;&gt;<br>&lt;CFSET qualifiedList1=ListQualify(myList,&quot;'&quot;,&quot;,&quot;,&quot;ALL&quot;)&gt;<br></b></font><br>will do exactly what you're looking for.&nbsp;&nbsp;If you change the &quot;ALL&quot; to &quot;CHAR&quot;, it'll only put the single quotes around the alpha strings and not numbers...<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top