Copy Code code as follows:
Dim RE
Set re = new RegExp ' Create REGEXP instance
Re. Pattern = "Ab+c" defines regular expression text, you can replace the regular expression here
Dim myString
myString = "ABCEFG" defines the string to match and can be replaced
Response.Write (Re. Execute (myString) (0)) ' matches the test and writes out the result
Copy Code code as follows:
<%
Dim RE
Set re = new RegExp ' Create REGEXP instance
Re. Pattern = "\w+" defines regular expression text
Dim myString
myString = "VBScript version 5.6 provides many new features."
' Match test and write whether the match was successful
If Re. Test (myString) Then
Response.Write ("Match success!") ")
Else
Response.Write ("Match not successful!") ")
End If
%>
Copy Code code as follows:
<%
Dim RE
Set re = new RegExp ' Create REGEXP instance
Re. Pattern = "\s" defines regular expression text, here is matching whitespace
Dim myString
myString = "VBScript version 5.6 provides many new features."
myString = Re.replace (myString, "-") ' replaces white space with--returns the replaced string
' Write the result
Response.Write (myString)
%>
Copy Code code as follows:
<%
Dim RE
Set re = new RegExp ' Create REGEXP instance
Re. Global = True
Re. Pattern = "\s" defines regular expression text, here is matching whitespace
Dim myString
myString = "VBScript version 5.6 provides many new features."
myString = Re.replace (myString, "-") ' replaces white space with--returns the replaced string
' Write the result
Response.Write (myString)
%>
Copy Code code as follows:
<%
Dim RE
Set re = new RegExp ' Create REGEXP instance
Re. Global = True
Re. Pattern = "(\w+)-(\w+)" ' defines regular expression mode text
Dim myString
myString = "Flip-flop"
myString = Re.replace (myString, "$1-$2")
' The first \w+,$2 represents the second \w+, the first \w+ matches the flip, the second \w+ matches the flop,
' So $1-$2 is equivalent to flip-flop
' Write the result
Response.Write (myString)
%>
Copy Code code as follows:
<%
Dim RE
Set re = new RegExp ' Create REGEXP instance
Re. Global = True
Re. Pattern = "(\s+) (\s+) (\s+)" ' defines regular expression mode text
Dim myString
myString = "Flip Flop"
myString = Re.replace (myString, "$3$2$1")
' The first \s+,$3 says that the second \s+,$2 represents \s+,
' So $3$2$1 is equivalent to flop flip
' Write the result
Response.Write (myString)
%>
Copy Code code as follows:
<%
Dim RE
Set re = new RegExp ' Create REGEXP instance
Re. Global = True
Re. Pattern = "\w+" defines regular expression mode text
Dim myString
myString = "VBScript version 5.6 provides many new features."
Set matches = Re. Execute (myString) ' performs the search, which is used to save matching results
' To test the match and write the result
' Iteration matches Collection
For the Match in matches
' Write the result
Response.Write (Match.firstindex & "-" & (Match.firstindex + match.length) & "& Match.value &" <b R/> ")
Next
%>
Copy Code code as follows:
<%
Dim RE
Set re = new RegExp ' Create REGEXP instance
' Re. Global = True comment out this line
Re. Pattern = "\w+" defines regular expression mode text
Dim myString
myString = "VBScript version 5.6 provides many new features."
Set matches = Re. Execute (myString) ' performs the search, which is used to save matching results
' To test the match and write the result
' Iteration matches Collection
For the Match in matches
' Write the result
Response.Write (Match.firstindex & "-" & (Match.firstindex + match.length) & "& Match.value &" <b R/> ")
Next
%>
Copy Code code as follows:
<% @language = "VBScript" codepage= "65001"%>
<%
' Create a connection, and create a adodb.command to manipulate the
Dim ocmd,oconn
Set oconn = Server.CreateObject ("ADODB. Connection ")
Set ocmd = Server.CreateObject (" ADODB. Command ")
Oconn.connectionstring =" Provider=sqloledb;server = myhost;initial Catalog = myDatabase; Uid=sa; Pwd=verysecret; "
oConn.Open
' creates an SQL CREATE TABLE statement
Set ocmd.activeconnection = oconn
Ocmd.commandtext = "Create TA BLE newemployees (firstName nvarchar, lastName nvarchar (), emptype nvarchar) "
Execute create datasheet operation
Ocmd.execut E
Response.Write (The operation was successful!) ")
%>
<%
' explicitly close connection
Oconn.close
Set oconn = Nothing
%>