basic usage of C # regular ExpressionsThe
Regular expression (regular expression) describes a pattern of string matching that can be used to check whether a string contains a seed string, replace a matched substring, or remove a substring from a string that matches a certain condition. [Http://www.runoob.com/regexp/regexp-syntax.html]For a description of the various characters of the regular expression, refer to the above link content. in C #, regular expression-related classes have regex, Match, matchcollenction, and so on. The following code matches the string in the ' | ' End of fragment: Regex regex = new Regex (@ "(. *?) \|"); MatchCollection mc = Regex. Matches (represults); int mccount = MC. Count; ArrayList Sqlarray = new ArrayList (); for (int i = 0; I < MC. Count; i++) {string matchresult = Mc[i]. GROUPS[1]. Value;regex = new Regex ("element (. *?)" (middle ");}
about group matching [reference: http://www.cnblogs.com/px7034/archive/2011/01/24/1943062.html]:
In ((\d+) ([A-z]) \s+ This regular expression contains a total of four groupings, according to the default left-to-right matching method, Groups[0] represents the match itself, that is the entire expression ((\d+) ([A-z]) \s+ groups[1] Represents a sub-expression item ((\d+) ([A-z])) groups[2] Represents a subexpression item (\d+) Groups[3] Represents a subexpression ([A-z])
Basic usage of [C #] Regular expressions