Search strings with regex

I have a txt file called test.txt

I want to take user input from cmd line and search this text file with regex - or anything for that matter...ive never used regex before so there are prob some errors in the code

Here is the function:

1
2
3
4
5
6
7
8
9
10
11
static string searchFunc(string a, string b){
	ifstream inp;
	inp.open(a, std::ios::in);
	string c;
	std::tr1::cmatch res;
	std::tr1::regex rx(b);
	while(getline(inp,c)){
		std::tr1::regex_match(c.c_str(), res, rx);
	}
	return res;
}


string a is the file location string b is the cin from the user that i want to use as search perams

I know im doing somthing wrong HA - Any help?
Topic archived. No new replies allowed.