Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all,

when ever user enters string i will append another string to it for splitting purpose,now i have to retrieve based on that string,how do i split it based on that?

the string i want to use for splitting is "~^@"

eg:this is an example string~^@today it has been added.

C#
Regex regex = new Regex(@"\b~^@\b");
string[] substrings = regex.Split("this is an example string~^@today it has been added");

i tried using this but it did not work.

thanks in advance,
Posted
Comments
Sergey Alexandrovich Kryukov 22-Dec-11 0:59am    
Not quite clear. What is the expected result of splitting?
--SA
girish sp 22-Dec-11 1:48am    
this is an example string
today it has been added

should be the answer
Rajesh Anuhya 22-Dec-11 1:45am    
Are expecting like this
"this is an example string"
"today it has been added"
???
girish sp 22-Dec-11 1:48am    
yes
you are right
Rajesh Anuhya 22-Dec-11 1:55am    
see my answer

why don't you use this

"this is an example string~^@today it has been added".Split(new string[]{"~^@"},StringSplitOptions.None)
 
Share this answer
 
Comments
girish sp 22-Dec-11 2:19am    
thanks buddy,works like a gem:)
hi

you can try below solution

string str = "this is ~!@ this is 1 ~!@ this is 2 ~!@ this is 4";

         string[] saprator ={"~!@"};

         String[] strSplit= str.Split(saprator,StringSplitOptions.RemoveEmptyEntries);
 
Share this answer
 
string []yourstring=the string
yourstring.substring(seperating Text or character);


Your will get it in arrary form check it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900