Reveal the truth about the regular expression lxfregex [Source]

Source: Internet
Author: User

Regular Expressions are widely used and often used for search and replacement.Programming LanguageAll of them support a variety of places, such as JS, Java, C # all have their own implementation classes, so it is very convenient to use.
I really want to figure out how he did it in every language, so before getting the source code, I first started to use the C # language to create a class that supports regular expressions, currently, the implementation function is very simple and supports the implementation of ismatch and relace to process basic characters,
CodeThere are many shortcomings. I hope you will forgive me.

Sample Code:

Lxfregex lxf =   New Lxfregex (txtregex. Text );


Stringbuilder sb =   New Stringbuilder ();
SB. appendline ( " Brackets " );

Foreach (Matchunit mu In Lxf. Matches (txtsrc. Text ))
{
SB. appendline ( " Match "   + IND ++ );
Int I =   0 ;
For ( Int J =   0 ; J < Mu. Groups. Count; j ++ )
{
SB. appendline ( " Group "   + J + Mu. Groups [J]. value );

Foreach (Captureunit t In Mu. Groups [J]. captures)
{
SB. append ( " Capture "   + I );
SB. append ( " Index: "   + T. Index +   " Length: "   + T. Length );
SB. append ( " = "   + T. value );
SB. appendline ();
I ++ ;
}
}
}
This . Txtmatch. Text = SB. tostring ();

Demo location:
Http://www.iyuyan.com/regexlove Language
Download source code:

Source code

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.