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