Home  |  Latest News  |  Contribute  |  F.A.Q.  |  Account  |  Scripts | About
Search ASPNut:
 
ASP Reference
Server Variables
ASP Glossary
Related Sites

Free Components

Web Colors
Entities
CSS Level 1
Encode/Decode
Glossary

Our Sponsors
ASP Nuke CMS
Free Auctions
PHP 5 Script
Funktastic Blog
ULost Directory
Team Task

 

 

 

 

 

 

 

 

 

 

 

 

Replace

The Replace function will replace occurances of one character string with another. The parameters for this function are the string you want to do the replacement for, the string to find and the string to replace it with.

This function is ideal for substituting one text string for another. You should be careful about which strings will be replaced so that you don't accidentally replace strings that you didn't intend to.

Dim sText
sText = "It's a Cat's Life"
Response.Write "Before: " & sText & "<BR>"
sText = Replace(sText, "Cat", "Dog")
Response.Write "After: " & sText & "<BR>"


The fourth parameter defines what type of comparison should be done for matching strings. The only two possible values are to do a binary comparison (case-sensative matching) or a textual comparison (case-insensative matching). By default, ASP will use binary comparison.

Dim sText
sText = "It's a Cat's Life"
sText = Replace(sText, "cat", "dog")
Response.Write "Binary Replace: " & sText & "<BR>"
sText = Replace(sText, "cat", "dog", vbTextCompare)
Response.Write "Textual Replace: " & sText & "<BR>"


For a more powerful method of doing string searching and replacement, you should refer to the object reference section about the RegExp object.

Orvado, San Diego Web Design

ASP Nuke CMS
Free Open Source
Content Manager
GoSwap Auctions
Buy, Sell
No Fees!

Contact Us | Contribute | About | Site Map



"I do not think much of a man who is not wiser today than he was yesterday." - Abraham Lincoln

©2012 San Diego Web Design - Orvado Technologies, All Rights Reserved
ASP Nut provides articles and reference documentation for Active Server Page developers.