by TimTheTinker · 5y ago · 0 comments
It would be one thing if this were a tool for generating a regex, which the developer then copies and pastes into the source code. But it’s expected that this syntax is checked in and maintained in the source, with all the requisite constraints and dependencies. It’s unportable to other languages, unreadable without the docs, and non-standard. It's also another runtime dependency that will need periodic security updates applied (I hope :-D). Meanwhile, there is a standard, built-in cross-language syntax for expressing these things (and great tools like https://regexr.com/ for reference).
Maybe this makes sense in one-off scripts, but I don't see it adding value where the code is intended to be a source of truth.
It could be horribly misused though so documentation would be important.
In many respects it feels to regexes like what an ORM is to a database. Probably pros and cons of each.
For me this is pretty cool, I don't have to write much REGEX mostly copypasta from stackoverflow. But when I do need something more unique REGEX is very hard/confusing for me to learn so this type of js property chaining makes sense in my mind.
Though when testing their GUI using the first example in their readme I can't get it to highlight the accepted text
// Produces the following regular expression:
/^(?:0x)?([A-Fa-f0-9]{4})$/
It would certainly be helpful to include the input to this API as a code comment along with a link to the playground, but you certainly don't need to do so, and there's very little reason to add a runtime dependency on this library.I'm inclined to agree. I guess the Playground (https://sepg.netlify.app/) together with the documentation is almost that.
Not sure if that will get you better/faster results than just learning regex though. Maybe it could be a good way to figure out some of the trickier regex stuff.