4 ms·
Regex, like SQL is a black art I'll never understand. At best I tolerate it. Usually easier to split the string into an array and manipulate it then.
by offtop5 6y ago
Regex, like SQL is a black art I'll never understand. At best I tolerate it. Usually easier to split the string into an array and manipulate it then.
- coldtea 6y agoWhat's so strange about regex? Or SQL for that matter?
- Zelphyr 6y agoBasic regex is readable, at a glance, for the most part, with a little practice. Anything marginally complex and you have to stop what you’re working on and really read the regex to try to understand what it’s doing. SQL isn’t hard, but trying to remember all the use cases for the various ways to query something always trips me up. “Wait, do I do a LEFT JOIN here? Ok, now I gotta to look up the different kinds of joins so I can be sure I’m writing the most efficient query.” Again, it’s just a matter of practice. I’d take SQL over a regex any day.
- offtop5 6y agoAs for SQL, I think I just don't put the time into learn it. At the higher levels, it's definitely it's own programing language with a radically different herritage from the JS/C# I'm used to.
- wpietri 6y agoThey're definitely different paradigms of thinking than typical coding. I enjoy regexes, but definitely get how other people would find them bizarre. Personally, I've never liked SQL, though. As with regexes, a little does no harm. But building anything substantial with it always turns into what feel like absurd bank shots to me. I don't just have to cast everything into the relational paradigm, I have to try to guess how a couple million lines of DB server code is going to map that back into operations I actually understand. That said, as with most technologies that I don't personally like, people seem to build sufficiently effective systems and profitable businesses on top of them. So I think it's down to personal cognitive differences and matters of taste. Let a thousand flowers bloom, I say.
- core-questions 6y agoIt's surprisingly more logical and straightforward than you might think. Just start small and work your way up. No doubt you already use wildcards when interacting with the shell; now just add little bits of syntax as you go until you can match more complicated things. You don't have to go as far as pattern extraction and backreferencing and all that to make some good use of it.
- wahern 6y agoCarefully read through (bottom up--main, slre_compile, etc) this short implementation and all will be clear: http://slre.sourceforge.net/1.0/slre.c http://slre.sourceforge.net/1.0/slre.c Also a great introduction to writing compilers.