Solved

Using Instr to find double quotes

Posted on 2002-07-15
6
1,981 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
6 Comments
 
LVL 8

Accepted Solution

by:
drittich earned 75 total points
Comment Utility
stringX = Replace(stringX, """", "'")
0
 
LVL 8

Expert Comment

by:drittich
Comment Utility
...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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 5

Expert Comment

by:funke
Comment Utility
easier yet -

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

Expert Comment

by:tejaspurani
Comment Utility
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
Comment Utility
Thanks drittich, works great.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now