我有一段文字
[:+ This is a message +:] text here ... [:+ This is another message +:] ..... text [:+ This message allows + , : , ]character +:]我希望将其中的
This is a message
This is another message
This message allows + , : , ]character
用一句正则提取出来, 请问哪位大虾能搞定啊? 谢谢
[:+ This is a message +:] text here ... [:+ This is another message +:] ..... text [:+ This message allows + , : , ]character +:]我希望将其中的
This is a message
This is another message
This message allows + , : , ]character
用一句正则提取出来, 请问哪位大虾能搞定啊? 谢谢
解决方案 »
- C# 大家帮忙看下 这个数据库查询的结果 怎么用到这个判断语句中呢
- 怎样点击一个按钮,让时间从1开始一秒一秒的累加,直到走完这个按钮的事件后,再让时间消失。
- DesignSurface做设计界面,出现死锁现象
- 对象序列化问题急救!大虾来帮忙!
- 请指教DataView中的数据导入EXCEL的方法
- PictureBox控件使用了ImageList里面的图片,为什么图片非常模糊? 万分感谢!
- 关于webconfig里的数据库虚拟配置,在线等!
- webpart
- 关于套接字的问题,在线等待!!!如何检测客户端的非正常断开。
- 奇怪的问题~~ 有关文件读写的~~~
- 面试题蚂蚁爬干---今天面试遇到的问题 不知道有哪位大哥能做出来
- 请高手们帮我推荐一本比较好的关于asp.net2.0网站建设方面的书籍
MatchCollection mc = Regex.Matches(test, @"(?<=\[:\+\s*)[\s\S]*?(?=\s*\+:\])");
foreach (Match m in mc)
{
richTextBox2.Text += m.Value + "\n";
}
/*输出
This is a message
This is another message
This message allows + , : , ]character
*/
Regex reg=new Regex(@"\[[^a-z]*([a-z\s]+)[^\]]*\][^\[]*\[[^a-z]*([a-z\s]+)[^\]]*\][^\[]*[^a-z]*([a-z\s]+[^\]]*\][a-z]*)\b");
string result=string.Empty;
Match m=reg.Matche(yourText);
if(m.Success)
{
result+=m.Groups[1].Value+"\r\n"+m.Groups[2].Value+"\r\n"+m.Groups[3].Value;
}
//将错就错,不循环,一次输出结果。修正上面的正则。
(?is)\[[^a-z]*([a-z\s]+)[^\]]*\][^\[]*\[[^a-z]*([a-z\s]+)[^\]]*\][^\[]*[^a-z]*([a-z\s]+[^\]]*\][a-z]*)\b