Skip to content

booster::regex_search usage #51

Description

@masaoliou

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|

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions