Recommended: Use ASP to plan chat rooms I'm afraid few netizens who often surf the Internet have never been to the chat room to chat randomly. Just pay a little attention and you will find that most of these chat rooms are maintained using CGI programs or Applets developed in Java. Programmers who have developed this type of CGI or Applet know that
Let's first look at the detailed parameters of Replace
describe
Returns a string where a specified number of some substrings is replaced with another substring.
grammar
Replace(expression, find, replace with[, compare[, count[, start]]])
The syntax of the Replace function has the following parameters:
Parameter description
expression Required. A string expression contains the substring to be replaced.
Find Required option. The substring being searched for.
replacewith Required option. Substring used for replacement.
start Optional. Start searching for the location of the substring in expression. If omitted, the default value is 1. Must use it when associated with count
count is optional. The number of substring replacements performed. If omitted, the default value is -1, indicating that all possible replacements are made. Must be used when associated with start.
compare Optional. Indicates the value of the comparison type used when calculating the substring. For values, see the Settings section. If omitted, the default value is 0, which means that binary comparisons must be performed.
set up
The compare parameter can have the following values:
Constant value description
vbBinaryCompare 0 Perform binary comparison.
vbTextCompare 1 Perform text comparison.
Return value
Replace returns the following values:
If Replace returns
expression is zero length zero length string().
Expression is Null error.
find is a copy of zero-length expression.
replacewith is a copy of zero-length expression, where all content specified by the find parameter is deleted.
start > Len(expression) Zero-length string.
count is a copy of 0 expression.
illustrate
The return value of the Replace function is a string that has been replaced (start from the position specified by start to the end of the expression string), rather than a copy of the original string from the beginning to the end.
The following example uses the Replace function to return a string:
The code copy is as follows:
Dim MyString
MyString = Replace(XXpXXPXXp, p, Y) 'Binary comparison starts at the left end of the string. Returns XXYXXPXXY.
MyString = Replace(XXpXXPXXp, p, Y, 'Text comparison starts with the third character. Returns YXXYXXY. 3, -1, 1)
Method 1: Use ASP's own function to replace it. This is also the easiest method.
title=replace(title,DF,SD,1,-1,1)
Detailed explanation of the parameters of the replace function:
Parameter 1: Source string
Parameter 2: Characters to be replaced
Parameter 3: New character. , , you must replace some characters in the source string with newly specified characters
Parameter 4: Value is 1. Specify searching for the string starting from the first character
Parameter 5: Value is -1 Specifies that each substring must be replaced
Parameter 6: Value 1 The comparison of the specified string is case-insensitive.
Two functions (highlight keywords)
Method 2: Replace the specified character with regular case insensitive
The following is the function source code:
The code copy is as follows:
'//Function: String replacement
'//Article: Regular expression, replaced string, replaced string
Public Function ReplaceTest(patrn, mStr, replStr)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
ReplaceTest = regEx.Replace(mStr, replStr)
Set regEx = Nothing
End Function
Share: Function of using ASP for network printing %@ Language=VBScript % % Option Explicit Dim strSubmit 'The value used in Form to save the submission button Dim strPRinterPath 'The value of the network printer path in Form Dim strUsername 'The value of the user name in Form Dim strPassWord 'The value of the password in Form Dim strMessage 'The value of the printed content Dim objFS 'VBScript