Add a note about double escaping in regexes.

This commit is contained in:
Alexander Kuzmenkov 2020-03-25 14:34:33 +03:00 committed by GitHub
parent fa219179f9
commit be75df7c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -281,8 +281,17 @@ OptimizedRegularExpressionImpl<thread_safe>::OptimizedRegularExpressionImpl(cons
re2 = std::make_unique<RegexType>(regexp_, regexp_options);
if (!re2->ok())
throw DB::Exception("OptimizedRegularExpression: cannot compile re2: " + regexp_ + ", error: " + re2->error() + ". Look at https://github.com/google/re2/wiki/Syntax for reference.", DB::ErrorCodes::CANNOT_COMPILE_REGEXP);
{
throw DB::Exception("OptimizedRegularExpression: cannot compile re2: "
+ regexp_ + ", error: " + re2->error()
+ ". Look at https://github.com/google/re2/wiki/Syntax "
"for reference. Please note that if you specify regex as an SQL "
"string literal, the slashes have to be additionally escaped. "
"For example, to match an opening brace, write '\\(' -- "
"the first slash is for SQL and the second one is for regex",
DB::ErrorCodes::CANNOT_COMPILE_REGEXP);
}
if (!is_no_capture)
{
number_of_subpatterns = re2->NumberOfCapturingGroups();