Today, when I changed a B2B e-commerce system, I found ASP regular expressions. Although I have been using ASP for a long time, I have never used regular expressions. This system has a good regular function, let's see for yourself.
CopyCode The Code is as follows: <%
Function regexptest (patrn, strng)
Dim RegEx, match, matches 'to create a variable.
Set RegEx = new Regexp 'to create a regular expression.
RegEx. pattern = patrn 'setting mode.
RegEx. ignorecase = false' is used to determine whether the character is case sensitive.
RegEx. Global = true' to set global availability.
Set matches = RegEx. Execute (strng) 'to execute the search.
For each match in matches 'traverses the matching set.
On Error resume next
Retstr = retstr & Match. Value & "|"
Next
Regexptest = retstr
End Function
STR = "I come from #5565 # haha"
Strinfo = regexptest ("# \ W + (\ B [, 0-9] + \ B )? \))? # ", STR)
Response. Write (strinfo)
%>
Let's look at another example:
Copy code The Code is as follows: function nohtml (STR)
Dim re
Set Re = new Regexp
Re. ignorecase = true
Re. Global = true
Re. pattern = "(\ <.*? \> )"
STR = Re. Replace (STR ,"")
Re. pattern = "(\ <\/.*? \> )"
STR = Re. Replace (STR ,"")
Nohtml = Str
End Function