Using system;using system.collections.generic;using system.linq;using system.text;using System.text.regularexpressions;using system.collections;namespace consoleapplication1{//<summary>//String regular Match Help class///</summary> public static class Regexhelp {///<summary>//Returns a single regular match value </summary>//<param name= "value" > String </param>//<param name= "regex" > Regular expression string </param>///<returns> String type </returns> public static string Toregexstring (the This string value , string regex) {if (value = null) {regex re = new regex (regex); Match m = Re. Match (value); if (m.success) {return m.value; } else {return null; }} else {return null; } }///<summary>///return a regular match string array///</summary>//<param name= "value" > String </param>//<param name= "regex" > Positive expression </param>//<returns> string array </returns> public static string[] Toregexstringarray (This string value, String regex) {string[] array = { }; if (value = null) {//compatible multi-line matching pattern regex = new Regex (Regex, Regexoptions.multil INE); MatchCollection MC = RG. Matches (value); if (MC. Count > 0) {int group = MC. Count; Array = new String[group]; for (int i = 0; i < group; i++) {array[i] = Mc[i]. Value; }}} return array; }//<summary>//To determine if match///</summary>//<PARam Name= "value" > String </param>//<param name= "regex" > Regular expression </param>///<returns>b ool</returns> public static bool Isregex (This string value, string regex) {if (Value! = Nu ll) {Regex reg = new regex (regex); Return Reg. IsMatch (value); } else {return false; } } }}
Regular tool class notation for C # common