hanickadot / compile-time-regular-expressions

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

Regex benchmark compile error #290

Closed Extra-Creativity closed 11 months ago

Extra-Creativity commented 11 months ago

I find a small benchmark to compare regex performance in different languages, and I'm trying to test it on this project. But this regex that is used to match Email seems not to compile:

R"([\w.+-]+@[\w.-]+\.[\w.-]+)"

Is this a bug?

hanickadot commented 11 months ago

you need to escape the dash inside character classes: [\w.+\-]+@[\w.\-]+\.[\w.\-]+ It's a consequence of CTRE's parser design and also my decision to not have "special" weird cases. In CTRE dash inside character class always needs A-B to mark range. If it's meant as a character, you need to escape it.