compile-time-regular-expressions
compile-time-regular-expressions copied to clipboard
look behind unimplemented
The following regex fails to compile with the error:
"Regular Expression contains syntax error."
I suspect it has to due to the digit look behind in the floating-point literals rule.
R"([a-zA-Z]{0,2}?(("|')(\2{2})?)((?:[^\\"]|\\.|\\)*\1)?|)" //capture strings - check later on if string
// prefix is valid and the string terminates
R"((#[^\r\n]*)|)" //capture comments
R"(([\n\r][ \t]*)|)" //capture newlines
R"((\\[^\r\n]*)|)" //capture \TheBackslashAndAnythingAfterIt
R"(()"
R"((\.{3})|)" //capture ...
R"((->)|)"
R"((\d*(\.\d*)?)(?<=\d)(([eE]-?[\d_]*)|[\w]*)|)" //floating point numbers
R"(([<>*\/]{2})=?|)" //capture 2-3 character operators
R"(([!%&*+\-<=>@\/\\^|:]=))" //capture 2 caracter operators
R"()|)"
R"(([!-\/:-@\[-^{-~]|[^\s!-\/:-@\[-^{-~]+)|)" //capture anything else
R"((\s+))" //capture whitespace in order to keep track of position with ctre
https://regex101.com/r/MkA1rH/1
Please minimise the regex.
Edit: The issue is the libary is mistaking (?<=\d)
as a sytax error
(\d*(\.\d*)?)(?<=\d)
https://regex101.com/r/Aq4bit/1 example code:
#include <ctre.hpp>
int main(void){
constexpr static ctll::fixed_string float_num = R"((\d*(\.\d*)?)(?<=\d))";
return ctre::match<float_num>("1.1");
}
https://gcc.godbolt.org/z/7Wzcae
Look behind positive nor negative is implemented.