I am trying to figure out how to create a regular expression in C++. I want to turn a string passed from JavaScript to C++ into a regular expression.
I have this:
std::regex re;
if (!args[1]->IsString()) {
Nan::ThrowTypeError("Second argument to 'replace-line' must be a string regular expression.");
return;
}
else{
v8::String::Utf8Value regexin(args[1]->ToString());
re(*regexin);
}
but this fails to compile, with this error:
../hello.cpp: In function ‘void Method(const v8::FunctionCallbackInfo<v8::Value>&)’:
../hello.cpp:50:16: error: no match for call to ‘(regex_t {aka re_pattern_buffer}) (char*)’
re(*regexin);
anybody know how I can declare/create a regex
given this v8::String
?
I am not sure about this, but maybe you have just declared regexin, but not initialized it? Have you tried doing
V8... regexin = new V8... (args...)
?