and I want to output a file which starts when the '830' is seen. At the moment I have the below code but I'm not sure how I go about starting the write process once the regex is true, any suggestions? At the moment it of course just writes any file where the regex is true
hmm, I currently have it as the below, but it is only outputting 1 the match + 1 character, how can I tell it to read until the rest of the line after the match?
while (std::getline(inputFile, line))
{
++lines_processed;
}
This is your base time to just read the file.
Then perhaps time this.
1 2 3 4 5 6 7 8 9
while (std::getline(inputFile, line))
{
++lines_processed;
bool match = std::regex_search(line, m, e);
if (match)
{
++lines_matched;
}
}
If it turns out that 90% of your time is spent just in file I/O, there isn't a lot you can do about it.
If your file is on rotating memory, the difference between the nS of your processor instructions, and the mS it takes the hard disk heads to move to another track is vast. There's no point improving the code just to spend longer waiting for more data.
The OS usually makes a good job of caching file reads ahead of need, but it's also easily possible for your code to catch up to the read-ahead and then be stuck waiting.
edit: it also stops reading the line once a character is hit rather than an int, what is the syntax to have it check all ascii aswell instead of 0-9?
clarify? If you want all ascii, don't check it at all, unless you are trying to weed out unprintable characters or upper ascii (> 127?) in which case >127 and < 10 (or whatever the value is for the unprintables, 20 is space, so its somewhere from 0-20ish).