Issue
I have the following piece of code
#include <string>
struct Confs{
std::string regexp;
};
class foo
{
public:
static int search(const std::string& phrase);
static const Confs configs[];
};
const Confs foo::configs[] = {
//Regular Expresion
{"^adb"}, //Example
{"^qwr"}, //Example
{"^a5eo"}, //Real
};
int foo::search(const std::string& phrase){
for(size_t i=0; i<sizeof(configs)/sizeof(Confs); i++){
std::regex re(configs[i].regexp);
if (std::regex_search(phrase, re)) {
return i;
}
}
return -1;
}
int main(){
std::cout << foo::search("a5eo_asd") << std::endl;
return 0;
}
When I search for "a5eo_asd" it does not find a match. Even removing the "^" at the begining. No match.
Compiled with ndk-build (clang, NDK 10d), and gnustl_static c++11.
However, the compilation with other toolschains make the same code to work (Android platform build, desktop g++). What is the ambiguous thing I am doing so that the code founds a match in a platform and not in another?
Solution
Try the open source free regex matcher (here). Its tiny, cross platform, extremely fast, and does not have any dependencies. Just copy the files into your source and you are ready to go
Answered By - DanielHsH
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.