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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing single quotation mark with double quotation mark

Status
Not open for further replies.

Albano

Instructor
Dec 11, 2000
221
PT
Hello,

I need a function that makes the replacement of single quotation mark with double quotation mark, because when the data is read from the database to the asp result page it ignores everything after the first quotation mark.

I already used the replace function but the problem is that the single quotation mark is just one and the double quotation mark are two.

Thanks,

Albano
 
Thats fine, character count doesn't matter to the Replace function in ASP, so:
Code:
Dim myString
myString = "whatever's here"
myString = Replace(myString,"'","''")
is perfectly valid.

In order to fix your problem I am going to make a mess, but it should work:
Code:
Dim myString = "string with a quote "" before me"
'resolves to single double quote in string
Code:
myString = Replace(myString,"""","""""")

Ok, so a double doublequote resolves to a single doublequote in an ASP String, so
" stuff "" stuff " resolves to stuff " stuff when you print it
So in our replace we need to strings, we want to match all quotes: """" 'resolves to a string with one doublequote in it
and replace with two quotes: """""" 'resolves to a string with 2 double quotes in it (should be at least)

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top