What i have
string ImageRegPattern = @"http://[\w\.\/]*\.jpg|http://[\w\.\/]*\.png|http://[\w\.\/]*\.gif"; string a ="http://www.dsa.com/asd/jpg/good.jpgThis is a good dayhttp://www.a.com/b.pngWe are the Best friendshttp://www.c.com";
What I want
string[] s; s[0] = "http://www.dsa.com/asd/jpg/good.jpg"; s[1] = "This is a good day"; s[2] = "http://www.a.com/b.png"; s[3] = "We are the Best friendshttp://www.c.com";
Bouns:
if the url can be broken as below, it will be better, but if not, it is ok.
s[3] = "We are the Best friends"; s[4] = "http://www.c.com";
What question
I am trying to use the following code to split a string,
string[] s= Regex.Split(sourceString, ImageRegPattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
But the result is not good, it seems that the Split method takes out all the lines that match ImageRegPattern. But I want them to stay. I am checking the RegEx page on MSDN, it seems that there is no suitable method to meet my needs. So how to do this?
source share