日期:2014-05-20  浏览次数:20807 次

求一正则
\nbook   Number:123\nbook   price:tt\nForward   Busy:tt\nForward   Number:tt\N

我想提取出123,就是:   和\N   之间的值

谢谢了

------解决方案--------------------
string s = "\nbook Number:123\nbook price:tt\nForward Busy:tt\nForward Number:tt\N
";
Regex regex = new Regex(@ "([\s\S]*?):([\s\S]*?)\n ", RegexOptions.IgnoreCase | RegexOptions.Singleline);

foreach (Match m in regex.Matches(s.ToString()))
{

MessageBox.Show(m.Result( "$1 "));
MessageBox.Show(m.Result( "$2 "));

}
------解决方案--------------------
string s = "\\nbook Number:123\\nbook price:tt\\nForward Busy:tt\\nForward Number:tt\\N ";
Regex regex = new Regex(@ "([\s\S]*?):([\s\S]*?)\\n ", RegexOptions.IgnoreCase | RegexOptions.Singleline);

foreach (Match m in regex.Matches(s.ToString()))
{

Response.Write(m.Result( "$2 "));

}
------解决方案--------------------
Text = Regex.Match(S, @ "123(?!\\N).*?\\N ").Value;
------解决方案--------------------
(? <=:).+?(?=\N)
------解决方案--------------------
@ "(? <=book Number:).+?(?=\\[Nn]) "
//呵呵 正则中\很特殊有时候为了一个\要写4个\(\\\\)
------解决方案--------------------
Text = Regex.Match(S, @ "\\nbook Number:[0-9]+\\((?!\\N).*?)\\N ").Result( "$1 ");
------解决方案--------------------
介是结果对马?
nbook price:tt\nForward Busy:tt\nForward Number:tt