hanickadot / compile-time-regular-expressions

Compile Time Regular Expression in C++
https://twitter.com/hankadusikova
Apache License 2.0
3.36k stars 186 forks source link

Named capture groups `(?P<name>...)` and `(?'name'...)` not implemented #325

Open alexios-angel opened 1 month ago

alexios-angel commented 1 month ago

The named capture groups (?P<name>...) and (?'name'...) are unimplemented. If these are implemented in CTRE's grammar then it will be closer to PCRE.

#include <ctre.hpp>

int main(){
    ctre::match<"(?<name>a)">;

    // These do not work
    ctre::match<"(?'name'a)">;
    ctre::match<"(?P<name>a)">;
}

Compiler explorer link

(?'test1'test1)|(?<test2>test2)|(?P<test3>test3)

Regex101 link

hanickadot commented 1 month ago

I'm not sure if this is worth more complex grammar. Functionality is there, will update README.

hanickadot commented 1 month ago

In longterm I would actually prefer to migrate to ECMAscript, as PCRE is really terrible turing complete syntax.