I have a task to search regex in many files.
How do you think is this code optimal by performance and complexity?
#include <regex>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <string>
int main(int args, char *argv[])
{
std::ifstream input;
std::string line;
input.open("test.ws");
std::getline(input,line);
line.erase(std::remove_if(line.begin(),line.end(),ispunct),line.end());
std::regex reg(argv[1]);
std::ptrdiff_t const matchCn (std::distance(std::sregex_iterator(line.begin(),line.end(),reg),std::sregex_iterator()));
std::cout << matchCn;
}
I'm trying to use STL for count number of regex in string getting from file.