Home  »  Code Snippets  »  C#.Net  »

How to split a string by using common words in c#?

 Posted By : Manoranjan SahooPosted Date : 29/03/2016 07:05:43 PM Category : C#.Net Points : 5

Suppose we have the below string :
"srkwersrktyusrkvbnsrkvfgsrkvbn"
In the above string we have "srk" common. We want to get the strings like below :
Output :
srkwer
srktyu
srkvbn
srkvfg
srkvbn

You can use the below code to split the string with common substrings:
string str = "srkwersrktyusrkvbnsrkvfgsrkvbn";
string[] strs=str.Split(new string[] {"srk"},StringSplitOptions.None);
for(int i=0;i<strs.Length;i++)
   Response.Write("srk"+strs[i]+"<br>");

Thank you.


Responses
No responses found for this thread. Be the first to respond this thread.
Post Reply
Login to post Response.