Searching and replacing strings inside another string using VBScript in ASPWe can search a string for presence of another string and replace it with a string by using Replace function of VBScript in ASP. This function search for the given string and replace it with another string. The search condition can be changed with optional arguments. We can also control with number of search and replace or replace all with matching strings. Here is the syntax of Replace() function.
Replace(string_var, string_find, string_replace, start, count, comparetype)Here inside replace function string_var is the main string inside which we will search for the string string_find and if found then it will be replaced with the string string_replace. Other arguments like start, count and comparetype are optional arguments. The argument start specifies from where the search and replace should start. The argument count specifies how many times the given search and replace operation has to work. The argument comparetype can take value of 0 and 1, here 0 means ( by default it is zero ) it is binary comparison so case sensitive as a result lower case text are different than upper case text. If the value of comapretype is set to 1 then it is a text comparison and lower case letters are treated same as upper case letters ( case insensitive ).
Here is a simple code example of Replace function.
The output of the above code is here
|ASP functions to handle string|
Adding two or more strings in ASP
Getting the size or length of the string by using len() function
Removing blank space before and after a string using trim function
Changing lower to upper or upper to lower case of text present inside a string
Reversing a string variable by using StrReverse function
Compare two strings in different ways by using StrComp function
Collecting parts from Left , right and middle areas of a string
Checking matching of a string inside another string using InStr function
Searching and replacing strings inside another string using Replace function
Creating arrays by splitting string using split() function
Joining elements of an array to create a string variable
Line Break by replacing text line break to html line break using Replace function