Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

split a string in to multiple strings

Tags:

c#

123\r\n456t\r\n789

How can i split the string above in to multiple strings based on the string text .split has only over load that takes char :(

like image 491
Kuttan Sujith Avatar asked Jun 13 '26 18:06

Kuttan Sujith


1 Answers

string.Split has supported an overload taking an array of string delimiters since .NET 2.0. For example:

string data = "123text456text789";
string[] delimiters = { "text" };
string[] pieces = data.Split(delimiters, StringSplitOptions.None);
like image 91
Jon Skeet Avatar answered Jun 16 '26 09:06

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!