正则表达式取特定字符串中间部分内容

不会正则表达式,这个比较常用,留用

注意group[0].value中带着两头筛选条件,group[1].value中没有 

            string str12="标注2";

            string pattern12 = "(.*?)";

            var m = Regex.Match(str12, pattern12,RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);

            string bs1 = m.Groups[1].Value;
            string bs2 = m.Groups[2].Value;


            string str3 = "标注3";
            string pattern3 = "(.*?)";


            m = Regex.Match(str3, pattern3,RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);

            string bs3 = m.Groups[1].Value;


            string str4 = "
标注4
"; string pattern4 = "(.*?)
"; m = Regex.Match(str4, pattern4,RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); string bs4 = m.Groups[1].Value;

你可能感兴趣的:(WinForm)