3 ms·
Tools like this keep appearing on HN, and I shudder every time I see them -- not because I don't like the idea, but because of the constraints involved in adopt
by TimTheTinker 6y ago
Tools like this keep appearing on HN, and I shudder every time I see them -- not because I don't like the idea, but because of the constraints involved in adopting it.
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/ 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.
- RamRodification 6y ago> 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 ... I'm inclined to agree. I guess the Playground (https://sepg.netlify.app/ 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.
- freedomben 6y agoThis is largely my opinion too, although with every non-trivial regex (especially with look-aheads and such) that I have seen committed, nobody knows what the hell it's supposed to do unless the original author commented the hell out of it, or is the one working on it (or can be consulted). In that respect something like this seems like a nice improvement since it's basically documentation! 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.
- ryanianian 6y agoThe very first example ends with: // 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.
- dillondoyle 6y agoThey list an online gui version to generate: https://sepg.netlify.app/ https://sepg.netlify.app/ 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
- wendyshu 6y agoSometimes people have to use things that are non-standard so that they can become standard. Besides, converting to and from standard regexes shouldn't be hard. Yes there are disadvantages to using a non-standard third party library but maybe there are advantage too.