Skip to main content
Inspiring
July 2, 2007
Question

replace 2 from the list

  • July 2, 2007
  • 2 replies
  • 434 views
hi,
I was trying to get 2 replaced from the list i've from database.
<cfquery name="test" datasource="test">
SELECT *
FROM test_new.backyard
WHERE weID = 2 OR meID = 2
</cfquery>
#ValueList(test.weID,",")# <br>
#ValueList(test.meID,",")#<br>

<cfset value1 = #ValueList(test.myID,",")#>
<cfset value2 = #ValueList(test.profileID,",")#>

<cfset valueCombined = value1 & "," & value2>
<cfset replacedList = #ReplaceList(valueCombined,"2","")#>
Replaced: #ReplaceList(valueCombined,"2","")#
<br>

ListChange: #ListChangeDelims(replacedList,"",",")#

At last, i end up having plain numbers 34556376 without any delimeters. But, i would like to have comma seperated list for further useage of numbers. I'm not sure which function to use to add comma's after every number.

Thanks for any help!

Note: I've got my user name changed, my previous screen name was Syed.
    This topic has been closed for replies.

    2 replies

    splitzerAuthor
    Inspiring
    July 2, 2007
    prasanth25 and jdeline, thanks for the help, i got it working!
    Prasanth_Kumar_S
    Inspiring
    July 2, 2007
    try using ListDeleteAt. Use the code below

    <cfset posInList = listfind(valueCombined,"2")>
    <cfif posInList GT 0>
    <cfset replacedList = #ListDeleteAt(valueCombined,posInList)#>
    <cfelse>
    <cfset replacedList = valueCombined>
    </cfif>

    July 2, 2007
    Another approach would be to use the code below to remove the 2 and any occurrences of double comma.

    Edit: made minor change in second Replace( )