3 ms·
While neat, I think that if you're a developer, you'd be better off learning basic regular expressions instead so you can use them in whatever language you'd li
by jjice 6y ago
While neat, I think that if you're a developer, you'd be better off learning basic regular expressions instead so you can use them in whatever language you'd like. Depending on this would probably just make moving to a new code base that doesn't use this a lot more confusing.
A normal regex with a comment above it explaining what it does (for complex cases) always worked well for me.
- TonyTrapp 6y agoEven as a developer you may have to assemble a regular expression at runtime, at which point a library that can do it for you may be much more handy than having to assemble the string yourself. And even if you know regex by heart - assembling it with function calls can still be better / safer just like you shouldn't insert SQL parameters by hand into your SQL query strings.
- nsxwolf 6y agoI can't learn them. I've tried for over 20 years and every time I use them the knowledge is deleted from my brain immediately. A library like this would be very helpful if it worked. One problem is that I'm more likely to need regex almost anywhere but Java code.
- rhacker 6y agoAt the bottom there's a list of other languages that support the same API
- spatx 6y agoI think there is value in both cases. I've seen many developers that have struggled with regex even with all those hundreds of tools to learn and to build/test regex. This could be useful to them to start with, and they can learn regex according to their time/needs. I see solutions like this as a choice, and the fact that people are using these shows that there is value in having that choice, even if is not obvious to us at first glance.
- patal 6y agoThat does not work so well if you're working in a team. A fairly complex regular expression is always hard to read. We see this as early as in code review and as late as when you find a production bug because expectations of the surrounding code have changed. For those reasons, we usually break regexes into parts anyway, and name and comment the single parts. Using the library's example, we might have: protocol = "^(?:http)(?:s)?" protocol_separator = "(?:\:\/\/)" url = "(?:www\.)?(?:[^\ ]*)$" regex = protocol + protocol_separator + url Which turns out to be in the direction of these Java Verbal Expressions. I find the Verbal Expressions idea really enlightening.