Home All Groups Group Topic Archive Search About
Author
27 Oct 2005 3:13 PM
Viraptor
Hello
How can I parse a string, which format I know, to elements. (in c#, not
using a regexp)
For example - it will be "number text = number text". Is there a faster
way to do it than getting string from start to IndexOf(" "), parsing to
number, getting next part to the next space, .....
I'm looking for something like c's sscanf

Author
27 Oct 2005 5:22 PM
Jon Skeet [C# MVP]
Viraptor <virap***@gmail.com> wrote:
> How can I parse a string, which format I know, to elements. (in c#, not
> using a regexp)
> For example - it will be "number text = number text". Is there a faster
> way to do it than getting string from start to IndexOf(" "), parsing to
> number, getting next part to the next space, .....
> I'm looking for something like c's sscanf

Three options:

1) Regex
2) String.IndexOf
3) String.Split

It's probably worth trying each of them to see which ends up being the
clearest - it'll depend on exactly what you need. In this case though,
I suspect a regex would be best.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

AddThis Social Bookmark Button