日期:2014-05-17  浏览次数:20756 次

求一个字符串截取的正则表达式
string str = "aaabbbcccdddeee";
现在我要截取到ddd
aaa,ccc和eee是固定的字符,但是bbb有可能是其他字符,这个正则表达式怎么写?
正则表达式

------解决方案--------------------
aaa(\w+?)ccc(\w+?)eee
------解决方案--------------------
(?<=aaa\w*ccc)\w+(?=eee)
------解决方案--------------------
本文来源于<a[^>]+>.*?</a>(?<datetime>[^<]+)

------解决方案--------------------
Regex rg = new Regex(@"(?:(?<=<span id=""cont_riqi"" class=""source"">本文来源于<a\b[^<]+</a>))[^<]+(?:(?=</span>))");

------解决方案--------------------
textBox1.Text = "aaabbbbddddccceee";

string str = textBox1.Text.ToLower();

            Regex g = new Regex(@"aaa(\w+?)dddd(\w+?)eee");

            
            MatchCollection mc = g.Matches(str);
            string strre = string.Empty;
            foreach (Match i in mc)
            {
                strre += i.Groups[1].Value + "        " + i.Groups[2].Value;
            }
            MessageBox.Show(strre);
//弹出bbbb  ccc