Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Replace Function

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,7
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Replace Function
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Replace Function - 5/22/2001 11:56:01 PM   
  nukeboy

 

Posts: 10
Score: 0
Joined: 5/22/2001
From: USA
Status: offline
I am trying to replace all occurances of double quotes (") in a string with single quotes ('). I have the following code that works for replacing words, but...
1. It only replaces the first occurance of the word.
2. I cannot figure out if I can change it to find and replace the quotes not a word.

Any suggestions?

The Function...

function ReplaceItem(patrn, replStr)
Dim regEx, str1
str1 = Request.Form("Reason") -->this is from my form
set regEx = New RegExp
regEx.Pattern = patrn
ReplaceItem = regEx.Replace(str1, replStr)
End Function

Here's how I call it...

<%Response.write( ReplaceItem("word2replace","withThis"))%>
 
 
Post #: 1
 
 Re: Replace Function - 5/22/2001 11:57:21 PM   
  hennykoe

 

Posts: 9
Score: 0
Joined: 5/23/2001
From:
Status: offline
Perhaps try doing the following function:

Function ReplaceQuote(inStr)

Dim inStrLen, quotChar
inStrLen = Len(inStr)
quotChar = Chr(34)
Replace(inStr, quotChar, "'", 1, inStrLen)

End Function

Syntax:
Replace(String, FindSTR, ReplaceSTR, Start, Count, Compare)

(in reply to nukeboy)
 
 
Post #: 2
 
 Re: Replace Function - 5/22/2001 11:58:25 PM   
  Mighty

 

Posts: 11
Score: 0
Joined: 5/22/2001
From: USA
Status: offline
ReplaceItem = Replace(str1, """","'")

(in reply to nukeboy)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Replace Function Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts