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

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12

    problems with rereplace


    I'd like to replace many single quotes to two single quotes.
    so:
    ''' to ''
    '''' to ''
    ''''''''''''''''''''''''''' to ''

    how do i do this with rereplace or any other method?

    thanks
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Buffalo, NY
    Posts
    156
    Rep Power
    12
    Is there a space at the beginning of the set of ''''s or anything else that is the same?

    I would think you would look the space and then your first '; then count the number of times you see the ' and then delete that number.

    Either that or do a loop, that starts at the space before the to (Is there always a space before the to?) and counts backwards until it doesn't see the '''s any more.

    Either way seems a bit convoluted.
    Forget Milk!
    Gotspy?

    www.gotspy.com
  4. #3
  5. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    This should work:

    <cfset teststring = "Some single quotes: and one ' and two '' and three ''' and four ''''.">
    <cfset teststring = reReplaceNoCase( teststring, "[']{3,}", "''", "All" )>
    <cfoutput>#testString#</cfoutput>
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12
    Kiteless,

    It worked perfectly!
    Thanks! :-)

IMN logo majestic logo threadwatch logo seochat tools logo