Extract words from a string

  • Thread starter Thread starter Maya
  • Start date Start date
M

Maya

Hello guys,

Is there an easy way to extract individual words that form a string and
store them in variables like in this example:

String "how are you?"

My result would be:

var1 = "how"
var2 = "are"
var3 = "you?"

Thanks alot,

Maya.
 
Try this:

string s = "How are you?";

strnig[] tokens = s.Split( ' ' );

string var1 = tokens[0];
strnig var2 = tokens[1];
string var3 = tokens[2];
 
Back
Top