All pastes #940460 Raw Edit

Miscellany

public cpp v1 · immutable
#940460 ·published 2008-03-12 23:56 UTC
rendered paste body
#include <boost/regex.hpp>#include <boost/filesystem/path.hpp>#include <boost/filesystem/operations.hpp>#include <iostream>#include <fstream>namespace bfs = boost::filesystem;int main(int, char**){	int line_no;	std::ifstream fh;	const boost::regex re("[A-Za-z]{5}-[A-Za-z]{3}");	std::string line;	const bfs::directory_iterator end;	for (bfs::directory_iterator it("."); it != end; ++it)	{		std::string filename = it->leaf();		if (filename.substr(filename.length() - 4) == ".txt")		{			fh.open(filename.c_str(), std::ifstream::in);			line_no = 0;			while(fh.good())			{				++line_no;				std::getline(fh, line);				if (regex_search(line, re))				{					std::cout << filename << " " << line_no << ": " << line << "\n"; 				}			}			fh.close();		}	}	return 0;}