日期:2014-05-18 浏览次数:21130 次
string reg=@"/?(\w+)[(|?]*.*";
------解决方案--------------------
string tempStr = File.ReadAllText(@"C:\Users\M\Desktop\Test.txt", Encoding.GetEncoding("GB2312")); string pattern = @"(?<=http://([^/(]*/)+)[^\s(?/]+(?=[(?\s])"; foreach (Match m in Regex.Matches(tempStr, pattern)) { string result = m.Value;//循环输出 Units }
------解决方案--------------------
List<string> list = new List<string>() { "/Units", "/Units(1)", "/Units(1)/Location", "/Units(1)?$expand=Location", "/Units?$expand=Location" }; string pattern = @"(?<=/)[^\s(?/]+(?=(?>(?([(?/]).+|$)))"; string[] array = list.Select(a=>Regex.Match(a,pattern).Value).ToArray(); /* * [0] "Units" string [1] "Units" string [2] "Units" string [3] "Units" string [4] "Units" string */
------解决方案--------------------
"/\.svc\/(.*)/"
可以吗?
------解决方案--------------------