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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ToString(string) and parsing 4
regexp - need help 5
parsing text file 2
Incrementing IPv6 address 1
Parsing XML 13
Help parsing string 3
Parsing Question 7
Excel Concatenate Form Name to Parse for function 1

Back
Top