NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

Case Sensitivity in the Replace Function

Written by Eric Smith, Northstar Computer Systems LLC

One of the newer VBScript functions, Replace, allows you to replace text within one string with other text. The simplest method for using this function is:
Response.Write Replace("This is a test", "test", "question")
This will replace the word 'test' with the word 'question'. It will find as many instances of the word 'test' as exist in the first string. However, this version will match case exactly. If you want to ignore case when you are matching text, you have to use a longer version of this function:
Response.Write  Replace("This is a test", "test", "question", 1, -1, vbTextCompare)
The fourth argument specifies which character to start at, the –1 indicates how many instances of 'test' to match. A –1 is the default value that indicates the function should match all the instances in the string. The last argument, vbTextCompare, indicates that comparisons should be done without regard to case. If you want to do exact matching, use the vbBinaryCompare value in place of vbTextCompare.

Keywords: [ ASP Built-in Functions ]

Publication Date: 10/1/2000, Last Update: 3/24/2010