i have this table:
List<string>
Total HTTP Packets 727 0.004459
HTTP Request Packets 372 0.002281 51.17%
GET 372 0.002281 100.00%
HTTP Response Packets 353 0.002165 48.56%
???: broken 0 0.000000 0.00%
1xx: Informational 0 0.000000 0.00%
2xx: Success 337 0.002067 95.47%
200 OK 331 0.002030 98.22
204 No Content 5 0.000031 1.48
206 Partial Content 1 0.000006 0.30
3xx: Redirection 10 0.000061 2.83%
302 Found 3 0.000018 30.00
304 Not Modified 7 0.000043 70.00
4xx: Client Error 6 0.000037 1.70%
408 Request Time-out 6 0.000037 100.00
5xx: Server Error 0 0.000000 0.00%
Other HTTP Packets 2 0.000012 0.28%
i want to parse this table into array (each line into 4 parts) but my problem is the first column because the string length changed.
i tty to split each line with Tab but unfortunately i did dot contain Tabs.
what is the best way to do it ?
I would use a regular expression (Regex class). Regular expressions rock for exactly this reason. Alternatively, if you’re getting the input as XML (which it doesn’t seem like you are), XPath might work for you too.
I prefer regex, because it’s simpler to write. You probably just need to know that
\srepresents empty space. The best place to write it is over at Rubular, where you can paste your content, type your regex, and see as you type how things match.