Reputation: 597
How can i get all the text after every occurrence of a string for example, I have to following text:
commonstring
text and more text and more
random text that may or may
not be on multiple lines
commonstring
more random text that
will be after the common string
How can I make that into an array of
{ "text and more text and more random text that may or may not be on multiple lines", "more random text that will be after the common string" }
Upvotes: 0
Views: 992
Reputation: 292455
Use this String.Split
overload:
string[] parts = s.Split(new[] { "commonstring" }, int.MaxValue, StringSplitOptions.None);
Upvotes: 1
Reputation: 32576
You'll want to use Regex.Split:
string[] result = Regex.Split(inputString, @"commonstring");
Upvotes: 0