DEV Community

Discussion on: Introducing fancy-regex - JS/TS regexes with whitespace, comments, and interpolation!

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

*Laughs in LPeg*

Collapse
 
lionelrowe profile image
lionel-rowe

I guess LPeg is a Lua thing, hadn't heard of it before. The docs here look pretty gnarly, but might just be because I'm more familiar with regex syntax 😂

I like the idea of lpeg.P(string) being an exact string match though. Currently, interpolated strings are treated as regex fragments like what you'd pass to the native RegExp constructor, so regex`a${'.'}` compiles to /a./, rather than /a\./. I think I'll keep this behavior as it's more intuitive, but might be worth adding a helper function for creating exact string matches.