Replace special characters in string

Results 1 to 3 of 3

Thread: Replace special characters in string

  1. #1
    Join Date
    Dec 1969

    Default Replace special characters in string

    I&#039;m trying to replace " (open/close quote) in a returned string with \" so it doesn&#039;t screw up my HTML. I don&#039;t know how to specify the quote in the replace function, and when I tried to specify something else to be changed (to make sure I was on the right track) the browser returned <BR><BR>Cannot use parentheses when calling a Sub<BR>/demo/user/video.asp, line 480, column 33<BR><BR>Can anyone help?

  2. #2 Guest

    Default not backslash - just double up

    Replace(txtString, """", "&amp;quot;")

  3. #3
    Join Date
    Dec 1969

    Default RE: Replace special characters in string

    \" is used in JS coding. HTML needs the &amp;quot; as Peter noted.<BR><BR>As for specifying the quote character, itself, you can either user """" (4 quote marks in a row!) or you can use Chr(39). Really!<BR><BR>Replace( text, Chr(39), "&amp;quot;" )<BR><BR>And the "cannot use parens when calling a sub" error has *nothing* to do with this. That&#039;s universally true in VBS: If you call a function, you use parentheses around your arguments. If you call a SUB, you don&#039;t. Simple as that. (You *can* use parens around the args to a SUB if you use the CALL keyword, but why?)<BR><BR>Are you sure you WANTED to call a SUB??? Maybe you need to call the line with the error *AND* the code that it was trying to call.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts