|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Parse a stringHello
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 Viraptor <virap***@gmail.com> wrote:
> How can I parse a string, which format I know, to elements. (in c#, not Three options:> 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 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 |
|||||||||||||||||||||||