Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using Instr to find double quotes

Posted on 2002-07-15
6
Medium Priority
?
2,271 Views
Last Modified: 2007-12-19
OK, I'm sure I''m going to see the code and say 'DUH', but I can't figure it out.  I need to check a string for double-quotes, and then replace them with single quotes or display a message telling the user to change it themselves.  I want to write the following to identify the double-quotes, but I know it's not right...

   if Instr(1, stringX, """, 1) = true then

How can I check for the double-quotes?

Thanks in advance
0
Comment
Question by:kcleary
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Accepted Solution

by:
drittich earned 300 total points
ID: 7154399
stringX = Replace(stringX, """", "'")
0
 
LVL 8

Expert Comment

by:drittich
ID: 7154402
...will replace them.  If you want ocheck, do this:

If Instr(stringX, """") > 0 Then
    'do something
End If
0
 
LVL 6

Expert Comment

by:ebosscher
ID: 7154425
the problem with your code kcleary is that to get a double quote in VBScript (or VB for that matter) you have to put two double quotes in a row inside your string.

you were trying three double quotes, but that will probably just give you an 'unterminated string' error, because it sees you open one string, close the string, and then open another string. (or not close the first one)

if you want only a double quote you need to put four double quotes  """" instead of """

cheers
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:funke
ID: 7154492
easier yet -

If Instr(stringX, chr(34)) > 0 Then
   'do something
End If
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 7154497
The only way to check it is
instr(1,strurl,chr(34))

T.P.
<%
Dim strurl
strurl = "a""b"
strurl = replace(strurl,"",chr(34))
Response.Write strurl & "<br>"
Response.Write instr(1,strurl,chr(34))
%>
0
 

Author Comment

by:kcleary
ID: 7154522
Thanks drittich, works great.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question