ASP Vbscript String Replace Function

by top54u.com 08 Aug, 2008

Vbscript String Replace function in classic ASP provides the functionality to replace the part of a string with another substring or replace a character with new substring or character. In ASP, vbscript replace function enables you to replace the special characters from the string such as #, %, $, @ etc. Vbscript Replace string function finds the specified string pattern in the target string and replaces its each occurrence with other substring value specified in the function. Vbscript Replace string function can be applied to the values of vbscript variable of string type.

 

Syntax for ASP Vbscript String Replace Function

 

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

 

Vbscript replace string function accepts 6 types of parameters as shown in the above syntax.

 

  1. expression: first parameter accepts the string expression value from which substring or character is to be replaced.


  2. find: second parameter accepts string expression or character to be searched from the specified string in the first string expression parameter.


  3. replacement: third parameter also accepts the string type value as a new replacement substring or character in place of find parameter value in the specified string expression.


  4. start: optional. Start parameter accepts the number type value to specify the start index position to find the substring to be replaced within the specified string in first parameter. Default value is 1.


  5. count: optional. Count parameter specifies the number of replacements to be done. Default value is -1, to replace all occurrences.


  6. compare: optional. Compare parameter accepts the name of the approach for string comparison. It supports the following two types of vb enum type parameters:

    vbBinaryCompare = 0: for binary comparison approach.
    vbTextCompare = 1: for text comparison approach.

    Deafult value for compare parameter is 0.

 

Except first 3 parameters of Vbscript Replace string function i.e. expression, find and replacement other 3 parameters are optional.

Click here to see the Examples of ASP Vbscript replace function…

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:33:00 AM




related videos.....
recent posts.....
top54u ezines.....