日期:2014-05-18 浏览次数:21018 次
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string[] data = { "aa", "a a", "a a", @"a a", @"a a", "a a", "a1a", "aaa" }; Console.WriteLine(@"a\s+a Singleline vs Multiline"); var result1 = data.Select((x, i) => i + ": " + Regex.IsMatch(x, @"a\s+a", RegexOptions.Singleline).ToString()); var result2 = data.Select((x, i) => i + ": " + Regex.IsMatch(x, @"a\s+a", RegexOptions.Multiline).ToString()); Console.WriteLine(string.Join("\r\n", result1.Zip(result2, (x, y) => x + "\t" + y))); Console.WriteLine(@"a.+a Singleline vs Multiline"); result1 = data.Select((x, i) => i + ": " + Regex.IsMatch(x, @"a.+a", RegexOptions.Singleline).ToString()); result2 = data.Select((x, i) => i + ": " + Regex.IsMatch(x, @"a.+a", RegexOptions.Multiline).ToString()); Console.WriteLine(string.Join("\r\n", result1.Zip(result2, (x, y) => x + "\t" + y))); } } }
------解决方案--------------------
(?isn)<selection\b\s+[^>]*type[^>=]*=("(?<type>[^"]+)"|(?<type>\S+))[^>]*?sel_id[^>=]*=("(?<sel_id>[^"]+)"|(?<sel_id>\S+))