Open masaoliou opened 5 years ago
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.
/
booster::regex_search
#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):
0
\0
|/a| |a| |00| |0|
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.output (the
0
's denote occurrences of binary zero,\0
):