Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Replace single quote in some text occurences

Community Beginner ,
Apr 11, 2008 Apr 11, 2008
Hi,

I'm trying to clean up my table with some entered data that has single quotes. I have created the following function to strip the single quote but it strips also normal text that has valid single quote in it. Anybody can help me replace single quotes within the url text and not those text i.e. 'bargain’s' that has valid single quotes? Thank you.

<cfscript> function killSingleQuotes(dbVal){
var outval = dbVal;
outval ="#ReReplaceNoCase(outval, '’/', '"/',"all")#";
outval ="#ReReplaceNoCase(outval, '’_top’', '"_top"',"all")#";
outval ="#ReReplaceNoCase(outval, '’', '"', "all")#";
return outval; }
</cfscript>

<cfset temp = "Where to bargain’s shop:<a href=’/things-to-do/venues/beacons-closet/4585/9812’ target=’_top’>beacon’s closet</a> in Williamsburg's<a href=’/things-to-do/venues/pearl-river/6226/12498’ target=’_top’>Pearl River Mart</a><a href=’/things-to-do/venues/strand-bookstore/5413/5355’ target=’_top’>Strand Bookstore</a><a href=’/things-to-do/properties/west-25th-street-flea-market/6770/’ target=’_top’>West 25th Street Flea Market</a> between Fifth and Sixth Avenues">

<cfset _sURL = "#killSingleQuotes(temp)#"><cfdump var="#_sURL#">
392
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Apr 16, 2008 Apr 16, 2008
I used the following to clean it up.

BEGIN TRANSACTION

UPDATE dbo.tips SET description = REPLACE(CAST(description AS VARCHAR(4000)),'href=’/', 'href=''/')

UPDATE dbo.tips SET description = REPLACE(CAST(description AS VARCHAR(4000)),'’ target=’_top’', ''' target=''_top''')

COMMIT TRANSACTION;

ROLLBACK TRANSACTION;
Translate
Participant ,
Apr 15, 2008 Apr 15, 2008
Did you try to use the functiuon #HTMLCodeFormat()#, it turns the qoutes into html "signs" ...

Tal.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2008 Apr 15, 2008
Hi,

You may also would like to use URLEncodedFormat() function which would take care of what you need...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2008 Apr 16, 2008
LATEST
I used the following to clean it up.

BEGIN TRANSACTION

UPDATE dbo.tips SET description = REPLACE(CAST(description AS VARCHAR(4000)),'href=’/', 'href=''/')

UPDATE dbo.tips SET description = REPLACE(CAST(description AS VARCHAR(4000)),'’ target=’_top’', ''' target=''_top''')

COMMIT TRANSACTION;

ROLLBACK TRANSACTION;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources