using System; using System.Text.RegularExpressions; namespace MetarCommonSupport { /// <summary> /// 通过Framwork类库中的Regex类实现了一些特殊功能数据检查 /// </summary> public class MetarnetRegex { private static MetarnetRegex instance = null; public static Meta
使用Regex类需要引用命名空间:using System.Text.RegularExpressions; 利用Regex类实现全部匹配输出 string str = "test4323232test432323"; Regex r = new Regex("test4"); MatchCollection m = r.Matches(str); //1.匹配所有出现的 foreach (var item in m) { Console.Write(item);