Parse a string

  • Thread starter Thread starter Viraptor
  • Start date Start date
V

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
 
Viraptor said:
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.
 
Back
Top