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

How To Replace Double Quotes with Single Quotes in String 1

Status
Not open for further replies.

scripter73

Programmer
Apr 18, 2001
421
0
0
US
Hi,

I need help replacing my double quotes of my log file with single quotes. I've heard there's two ways to do this: 1) By using the RegExp Object, and 2) simply using the Replace() function.

I haven't had any luck using the RegExp object, because I can't create a new instance of the object.

Can someone check out my code and advise.


<html><head><title></title></head>
<body>
<%


Dim str ' some string that needs to have certain words
' replaced with other words
str=&quot;10.11.130.80 - - [01/May/2001:13:52:59 -0600] &quot;GET /insuredacct/index.cfm HTTP/1.0&quot; 200 355 &quot;

Dim objRegExp
Set objRegExp = New RegExp

objRegExp.IgnoreCase = True
objRegExp.Global = True

'Replace all instances of Apache with IIS
objRegExp.Pattern = &quot;\bApache\b&quot;
str = objRegExp.Replace(str, &quot;IIS&quot;)

'Repalce all instances of Perl with ASP
objRegExp.Pattern = &quot;\bPerl\b&quot;
str = objRegExp.Replace(str, &quot;ASP&quot;)

Set objRegExp = Nothing 'Clean up!

response.write str

%>

</body>
</html>


I just want a ' every where there's a &quot;.

Thanks in advance,
scripter73
 
replace(str, &quot;&quot;&quot;&quot;, &quot;'&quot;)

will replace any &quot; with a ' in the string, 'str'

:)
Paul Prewett
 
Actually, I found that you need to put
replace(str, '&quot;', &quot;'&quot;, &quot;ALL&quot;)

Can't declare double quote with double quote. You have to use single quotes around the double quote.

Hope this helps

Joe
 
&quot;ALL&quot; ??

Where did that comes from? Hmm.

The correct syntax is:

Replace(expression, find, replacewith, start, count, compare)

The last 3 params are optional.

And yes, you certainly can use quotes in quoted strings, same as in VB. You simply double the quotes:

strSentence = &quot;Sam said, &quot;&quot;Wow!&quot;&quot;&quot;

gives:

Sam said, &quot;Wow!&quot;

For the value of strSentence.

When it doubt, look it up! ;-)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top