extracting tokens from strings

  • Thread starter Thread starter Jay Nesbitt
  • Start date Start date
J

Jay Nesbitt

Is there a quick way to extract tokens from a string of text? I know Java
provides a StringTokenizer class to do this. Is there something similar in
the dot net framework?
Ex.
string s = "some text then #token1# and then #token2#";
string[] tokens = tokenizer.GetTokens(s, "#");

The contents of the tokens array would then be token1 and token2.

Thanks!
 
Jay,

There is nothing like this in the .NET framework, but you could probably
roll your own very easily, or there might be someone else that has done it.

Also, you might want to try regular expressions if you are looking for
this kind of functionality.

Hope this helps.
 
The .NET Framework has a regular expression parser at
namespace:

System.Text.RegularExpressions

Keywords: Capture, CaptureCollection, Regex

--Richard
 
Back
Top