Regular expression Getting started Case C #

Source: Internet
Author: User

---restore content starts---

Baidu on the Internet a lot about regular expression, but a lot of it is about the grammar, there is no specific case, a bit difficult to get started, after all, I still like from concrete to abstract understanding. So I'm here to provide a small case of entry (learned about 6 months of Java, now transformation C #, may be some details can not, please advise)

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Text.RegularExpressions;usingSystem.Threading.Tasks;usingMicrosoft.SqlServer.Server;namespaceconsoleapplication6{classProgram {Static voidMain (string[] args) {            Const stringMyText =@"thiscomprehensive Compendium provides a broad and thorough investigation of all aspects of programming with ASP. Entirely revised and updaeted for the fourth release of. Net,this book'll give you the information to master ASP. NET and build Adynamic,successful,enterprise Web application."; stringPattern =@"\bn"; MatchCollection mymathches= Regex.Matches (MyText, pattern, regexoptions.ignorecase |regexoptions.explicitcapture); foreach(Match NextMatchinchmymathches)            {Console.WriteLine (Nextmatch.index); }        }    }}

Note the symbol at the front of the string @ (function here: indicates where the escape character is "not" handled). Pass the \b to when you want to run it again. NET regular expression engine, a backslash (\) should not be interpreted as an escape sequence by the C # compiler. If you want to find the word that ends with the sequence ion, you can apply the following code:

const string [email protected] "ion\b";

Now that we have a general idea of how to use regular expressions after running the process sequence, the syntax of the regular expression is saved:

Just provide a connection, because there are really a lot of grammar introduction, the official website also has OH.

http://www.imooc.com/article/8419

I believe that after reading these grammars, we should see this again.

Well, that's the end of it. Hope to help you get a quick start

Regular expression Getting started Case C #

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.