Regular Expression: adds a domain name to the site Link

Source: Internet
Author: User

1. Test text

 
<A href = 'HTTP: // search/. aspx '> Home </a> <a href ='/AAB/BB '> Hello </a> <a href = 'HTTP: // www.sohu.com '> Sohu </a> <p> sdfsf </P> <a href = "/AAB/BB"> Hello </a> <div> Hello World </div> <a href = "Aaa/BB"> </a>

 

2. Add domain names for intra-Site Links

 using system; using system. collections. generic; using system. LINQ; using system. text; using system. text. regularexpressions; using system. io; namespace consoleapplication1 {class program {static void main (string [] ARGs) {string S = file. readalltext (@ "C: \ a.txt"); // Add a domain name to all non-HTTP links. no/string d = RegEx before the link. replace (S, @ "

A. does not contain HTTP ,(?! HTTP.

B. Non-Greedy match?> Indicates that the first match exists.

C. $1 indicates the previous Group 1.

D. Double quotation marks \ "" in the Mode \""

E. Double quotation marks are represented by two "" characters in the @ escape string.

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.