请教一个正则式的写法
文本格式如下>1sdfklasdklfasdkfjk>asdfjksdfjklklasdf>asdjflaklsdf>
要分割为如下
>1sdfklasdklfasdkfjk>
>asdfjksdfjklklasdf>
>asdjflaklsdf>
谢谢! --------------------编程问答-------------------- 有人知道吗?谢谢! --------------------编程问答-------------------- 匹配@"(?<=[\w])>(?=[\w])"
换成">\r\n>"
试试吧
--------------------编程问答--------------------
resultString = Regex.Replace(subjectString, @"(?<=[\w])>(?=[\w])", ">\r\n>"--------------------编程问答--------------------
void Main()
{
string str=">1sdfklasdklfasdkfjk>asdfjksdfjklklasdf>asdjflaklsdf>";
foreach(string s1 in str.Split(new char[]{'>'},StringSplitOptions.RemoveEmptyEntries).Select(s=>">"+s+">"))
{
Console.WriteLine(s1);
}
/*
>1sdfklasdklfasdkfjk>
>asdfjksdfjklklasdf>
>asdjflaklsdf>
*/
}
论坛签名======================================================================
ioriliao12:你好!
截至 2011-03-15 11:22:27 前:
你已发帖 9 个, 未结贴 0 个;
结贴率为: 100.00%
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html
如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖
如何给自己的回帖中也加上签名?
http://blog.csdn.net/q107770540/archive/2011/03/15/6250007.aspx --------------------编程问答-------------------- --------------------编程问答--------------------
void Main()
{
string str=">1sdfklasdklfasdkfjk>asdfjksdfjklklasdf>asdjflaklsdf>";
foreach(string s1 in Regex.Split(str,">",RegexOptions.IgnoreCase))
{
Console.WriteLine(s1==""?"":">"+s1+">");
}
/*
>1sdfklasdklfasdkfjk>
>asdfjksdfjklklasdf>
>asdjflaklsdf>
*/
}
补充:.NET技术 , C#