62,046
社区成员
发帖
与我相关
我的任务
分享
string str = "hello,world<!--nextpage-->www.microsoft.com<!--nextpage--><p>www.google.com<img src='/images/1.gif' /></p><!--nextpage--><h3>test</h3><!--nextpage-->";
Response.Write(str.Substring(0, 11));
Response.Write(str.Substring(26,17));
string str = "hello,world<!--nextpage-->www.microsoft.com<!--nextpage--><p>www.google.com<img src='/images/1.gif' /></p><!--nextpage--><h3>test</h3><!--nextpage-->";
string[] sp = { "<!--nextpage-->" };
string[] arr = str.Split(sp, StringSplitOptions.RemoveEmptyEntries);
var result=Regex.Matches(str,@"(?s)<!--.*?-->").OfType<Match>();
var count=result.Count();
result.ToList().ForEach(x=>{
Response.Write(x.Value);
});
void Main()
{
string str = "hello,world<!--nextpage-->www.microsoft.com<!--nextpage--><p>www.google.com<img src='/images/1.gif' /></p><!--nextpage--><h3>test</h3><!--nextpage-->";
string[] result=Regex.Split(str,"<!--nextpage-->",RegexOptions.IgnoreCase).Where(x=>!string.IsNullOrEmpty(x)).ToArray();
int count=result.Count();
result.ToList().ForEach(x=>Console.WriteLine(x));
/*
hello,world
www.microsoft.com
<p>www.google.com<img src='/images/1.gif' /></p>
<h3>test</h3>
*/
}