Regular expressions in [ASP] use code _ Regular expressions

Source: Internet
Author: User
Today in the change of a business-to-business e-commerce system, found that the ASP is positive, although using ASP for a long time, but never used regular expression, this system has a regular function is very good, I see it.
Copy Code code as follows:

<%
Function regexptest (PATRN, STRNG)
Dim regEx, Match, matches ' Set variable.
Set regEx = New RegExp ' establishes a regular expression.
Regex.pattern = Patrn ' Set mode.
Regex.ignorecase = False ' Sets whether the character case is case-sensitive.
Regex.global = True ' Sets global availability.
Set matches = Regex.execute (strng) ' performs a search.
For the match in matches ' traversal matching collection.
On Error Resume Next
Retstr = retstr & match.value& "|"
Next
Regexptest = Retstr
End Function

str = "I'm from #5565# haha"
Strinfo = Regexptest ("#\w+" ((\b[,0-9]+\b))? # ", str)
Response.Write (Strinfo)
%>

Look at one more example:

Copy Code code 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.