compile-time-regular-expressions
compile-time-regular-expressions copied to clipboard
Syntax error on lookbehind expression
trafficstars
CTRE doesn't seem to support lookbehind rules, like (?<=x) or (?<!x).
Compiler-explorer / GCC trunk reports a failed assertion in functions.hpp:
/opt/compiler-explorer/libs/ctre/master/include/ctre/functions.hpp:74:23: error:
static assertion failed: Regular Expression contains syntax error.
Example:
#include <ctre.hpp>
constexpr bool a_not_preceded_by_b(const std::string_view s)
{
constexpr auto pattern1 = ctll::fixed_string{ "[^b](?=a)" }; // Works
constexpr auto pattern2 = ctll::fixed_string{ "(?<!b)a" }; // Fails
return ctre::search<pattern2>(s);
}
static_assert(a_not_preceded_by_b("xa"));
static_assert(!a_not_preceded_by_b("ba"));
Is this a known issue? The lookahead expressions (?=x) and (?!x) seem to work though.
It's not implemented. If you want, send a PR.
@hanickadot Any progress/alternatives?