The technique of replacing functions with regular expression chains--regular expressions

Source: Internet
Author: User
Tags regular expression

The technique of replacing a regular expression chain with a function is as follows:

1)

The character before the string <a href= "http://www.aaa.cn/000011.html" > any length character </a> following character

Replace with the previous character <a href= "http://www.bbb.cn/folder/show.asp?id=000011" > any length character </a> after character

2)

The character before the string <a href= "http://www.aaa.cn/070006,ccc.html" > any length character </a> following character

Replace with the previous character <a href= "http://www.bbb.cn/folder/aa.asp?id=000011" > any length character </a> after character

3) do not belong to the above situation, directly delete the link

The character before the string <a href= "http://www.aaa.cn/dddd.html" > any length character </a> following character

Replace the character behind any length character of the preceding character

The function's style is as follows, helps write the regular expression, thanks.

Function scripthtml (Byval constr,ftype)
  Dim Re
  Set re=new RegExp
  re.ignorecase =true
  Select Case FType
  Case 1
    re.pattern= "Regular expression"
    constr=re.replace (Constr, "") Case
  2
    re.pattern= "Regular expression"
    constr= Re.replace (Constr, "") case the other end
  Select
  scripthtml=constr the
  Set re=nothing end
Function

The above content is about the regular expression chain replaces the function the skill, hoped everybody likes.

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.