#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    1
    Rep Power
    0

    Going Crazy! Replace( ) on double quotes???


    I want to remove all the double quotes from a string which changes in length. I 've tried several different ways to remove the double quotes but nothing will work.

    Here are some of the different ways I've tried

    <CFSET keywords = ReplaceNoCase(keywords,Chr(22),"","ALL")>

    <CFSET keywords = ReplaceNoCase(keywords,Chr(34),"","ALL")>

    <CFSET keywords = ReplaceNoCase(keywords,"""","","ALL")>

    <CFSET keywords = ReplaceNoCase(keywords,'"','','ALL')>

    I've also tired turning the string into HTML edit format and try removing the &aspr; crap from the string that didnt' work either.

    I'm sure there is an easy solution, any ideas? Thanks in advance.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    16
    Rep Power
    0
    I don't see, why your 3rd line shouldn't work. So what error message do you receive, when you try it?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Boston, MA
    Posts
    47
    Rep Power
    12
    I think you need 3 quotes for the replace:

    <CFSET keywords = ReplaceNoCase(keywords,"""",""","ALL")>
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,280
    Rep Power
    968
    You should be able to do this by using single quotes within the function...like this:

    <CFSET keywords = ReplaceNoCase( keywords,'"','','ALL' ) />

    So after keywords you have single quote ' then a double quote " and then another single quote to close it '.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    1
    Rep Power
    0

    Use ASCII Representation


    I could not get the suggestion above to work. If you're still having trouble, try this:

    <cfset QuoteMark = Chr(34)>
    <cfset washedValue = Replace(originalValue, QuoteMark, "", "all")>
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0
    Not certain if it will suit your application but in a .cfm file I have the following line that works in javascript:
    document.xyz.variable.value=document.xyz.variable.value.replace(/"/g,"'");

    Where xyz is the form name containing the variable.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Talking I do it like this:


    <CFSET keywords = ReplaceNoCase(keywords,'"',"'","ALL")>

    I single quote the double quote, and double quote the single. It will make you cRaZy, especially when you working with SQL output like this:

    <cfset NewRow = '#NewRow#,' & Chr(34) & '#Replace('#altAddress1# #altAddress2# #altCity# #altState# #altZip# #altCountry#','"',"'",'ALL')#' & Chr(34)></cfif>

    In this example - I am removing the quotes from the output but reapplying them to the "NewRow" string that I am building from the SQL output.

    Good Luck!

IMN logo majestic logo threadwatch logo seochat tools logo