hanickadot / compile-time-regular-expressions

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

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

Open alexios-angel opened 1 week ago

alexios-angel commented 1 week 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 week ago

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

hanickadot commented 1 week ago

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