Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi all,

I like to know how to split a sting between two words i.e, if the string is

"HELLO MY DEAR FRIEND HOW ARE YOU"

i like to split

"HELLO HOW ARE YOU"

is possible to define the split function between two words....

Thanks in advance

seshu
Posted

Your question is somewhat confusing.

Split method returns array of string. Example

VB
Dim words As String() = "HELLO MY DEAR FRIEND HOW ARE YOU".Split(New Char() {" "c})

will return array of
HELLO
MY
DEAR
FRIEND
HOW
ARE
YOU.

"HELLO HOW ARE YOU" this can be achieve using Substring method of String class.

Or you can explain your question by using Improve Question widget.
 
Share this answer
 
Comments
Abhinav S 26-Aug-11 2:43am    
Simple. My 5.
Suresh Suthar 26-Aug-11 2:45am    
Thanks Abhinav.
hiseshu 26-Aug-11 6:38am    
Thanks suresh ... i got the solution by using substring method...
angeleena 26-Aug-11 14:01pm    
nice
you can split your string with String.Split() method, which will return you a array of words.

with your requirement, u need to split the string with " "(space). will return you a array with words. now use loop and make string whatever you want.
 
Share this answer
 
For more complex secnarios we could use a regular expression to split a string. However here, split is the best solution.
 
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