Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

booster::regex_search usage #51

Open
masaoliou opened this issue Jan 9, 2019 · 0 comments
Open

booster::regex_search usage #51

masaoliou opened this issue Jan 9, 2019 · 0 comments

Comments

@masaoliou
Copy link

I am trying to catch the first occurrence of characters between two slashes /. booster::regex_search yields correct result from the short string but wrong result from the long string as shown in the following code.

#include <booster/regex.h>
#include <fstream>
const char *s[]=
{
	"/a/b/c/d"
	,"/w/x/y/z/se1BoTdXG8sdR-G3or8wTOVpO2kRwNWkaG5yauoIeHqv_otH9D00i1xILrrG7lEl9HVMKA"
};
int main()
{
	std::ofstream of("/tmp/log",std::ios_base::out);
	booster::smatch match_result;
	for(int i=0;i <= 1;++i){
		if(booster::regex_search(std::string(s[i]),match_result,booster::regex("/([^/]+)"))){
			for(int j=0;j <match_result.size();++j)
				of << "|" << match_result[j].str() << "|" << std::endl;
		}
	}
	of.close();
	return 0;
}

output (the 0's denote occurrences of binary zero, \0):

|/a|
|a|
|00|
|0|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant