We have a
string text = "SOME OTHER TEXT WHITE SPACES AND NEW LINES [HitObjects] 109,192,7241,1,0,0:0:0:0: 256,192,7413,1,0,0:0:0:0: 475,192,75865,1,0,0:0:0:0: 329,192,86524,1,0,0:0:0:0: 182,192,256242,1,0,0:0:0:0: 256,192,306521,1,2,0:0:0:0: WHITE SPACES AND NEW LINES "
The third number of every row is the milliseconds. I need to know the seconds between the first time and last time. Right now I'm doing it like this:
text = text.Substring(text.IndexOf("Objects]") + 8).Trim(); string lines = text.Split('\n'); string firstLine = lines.Split(','); string lastLine = lines[lines.Length - 1].Split(','); int length = Convert.ToInt32(lastLine) - Convert.ToInt32(firstLine); length = length / 1000;
I need to do this with thousands of 'text's though. Any optimalization or other methodes possible?
more information on the request of @Slothario:
- the string text is the full text of 1 file
- file type: .osu
- average file size: 25KB
- average characters: 30000
- SOME OTHER TEXT - HitObjects ratio: 1 - 100
- average amount of files to check: 500