4 ms·
A programmer saying they are terrible at regex is like a mathematician saying they are terrible at algebra.
by Retra 9y ago
A programmer saying they are terrible at regex is like a mathematician saying they are terrible at algebra.
- m3kw9 9y agoMobile programmers doesn’t need regex nearly as much as serverside
- Retra 9y agoJS programmers don't need to know how a C pointer works, but they're not doing themselves any favors by being ignorant of it. It's very basic basic background knowledge.
- m3kw9 9y agoI meant to say they do not need to be great beyond basics like using wild cards, and simple Inclusion and exclusion syntax. That’s probably more than 50% of time all you need on that side of he world
- Retra 9y agoYeah, that's true. If you understand the quantifiers and matching groups, you basically understand regex. That's all I'm referring to. I'm not saying everyone has to be an expert on implementing them.
- stochastic_monk 9y agoI’m not terrible at it, but while useful in general, I rarely use regular expressions in the core programs I develop. I think the automata theory behind them is more important to know than proficiency with specific regular expression implementations.
- roel_v 9y agoRegex is useful when you do lots of string processing, like in webdev. Outside of that, I've found uses to be very limited - certainly not worth the upfront time investment. (I mean, sure one can cobble together something that mostly works with a regex testing tool, but you need to either take a college automata course or work through the Friedl in detail to get a basic level of proficiency).
- wruza 9y agoI’ve found otherwise. No single work day passes without me inspecting/converting/refactoring calls and complex expressions via regex. Tools define the way you think and create.
- rxhernandez 9y agoI use a regular expression maybe a couple days out of the year; it seems they don't come up very often in real-time biomedical algorithms engineering. I'm sure most embedded programmers feel the same way.
- bmn__ 9y agoAll programmers' text editors include search/replace with regex and external filter commands (of which many of the often used are regex-enabled). If the biomed or embedded programmer deliberately does not make use of that functionality, he is inefficient.
- steve_adams_86 9y agoWhat if needing to search and replace in the first place is inefficient? Also, what if that engineer is female? Is he still inefficient? I'm finding these comments hilarious. No true programmer!
- roel_v 9y agoRight - and regex makes you think about function and variable names as strings, instead of as the higher level abstraction that an IDE with proper refactoring support lets you think. Regular expressions are not the right tool for that sort of work in 2018. Look, I used to write web application in the 1990's with vim on computers with video cards that didn't have X drivers for them. I'm well versed in regular expressions, having used maybe a dozen flavors of them over the last 20 years. Being snooty about how useful regular expression should be (in your opinion) to the work of every other programmer out there isn't going to change the experiences of those others. I maintain that for web development there are quite often uses, but for scientific software (which is what I do), embedded, non-web based CRUD/LoB, and many other applications - it's just not what it used to be. EDIT: turns out I was mixing up the tone of your comment with that of bmn__ down below so I replied more belligerent than your comment warrented - no offense, I'm just going to leave it up regardless.
- rxhernandez 9y agoYou are so right! How could you possibly go out of practice in real-time biomedical algorithms engineering when you might use them one or two times out of the year?! I must have missed the memo where all those strings are encoded in a patient's hemodynamic signal. There are few people more frustrating to algorithms engineers and embedded engineers than people like you who think you are the only type of programmers out there or that the programming you do is somehow superior(despite largely relying on math you learned at a decent secondary school).
- wruza 9y agoI see many people treat regex as an in-app library and argue about that. But in fact it is a text processing tool. It is not important if you're biomed-dev with a honorable degree or web-dev from 'secondary school'. What is important is how you manage your code and constant data, which is mostly text that doesn't care who you are. How do you manage your code? What do you do if you understand that you need a module extraction? Documentation fixes? Managing any text includes non-trivial search and replace or specific tools, right? Either you know one of these, or you leave your mess as is. If former, you have to know something anyway. If latter, well... not much honor.
- laythea 9y agoI agree. If I ever need to use regex, I will dive in, but I don't mainly write software to process text. I mainly write control software for various things like subsea oil wells, oil rigs, gas turbines etc. It is enough for me to know it exists. I try to spread myself thin and broad, and then that gives me the control of which areas to dive deep, depending on the task at hand.
- deleted 9y ago[deleted]
- Retra 9y agoWell, maybe I think that the ability to use the search and replace function in a text editor is a foundational skill. Maybe you're a better programmer? I know programmers who don't even need to write code, but I wouldn't think they were good programmers.
- GeoffKnauth 9y agoIf I'm writing code that uses regexs, it helps me if I write at least 1 test case along with a helper function to make using the regex easier for me. E.g., I did the following in Scala recently. Shown is just one of many regexs I used to read SQLServer stored procedures and turn them into functions that would write the Scala code to use them. val inputIdTypWidthPat = new Regex("""(?si)@(\w+)\s+(\w+)\((\d+)\)""", "id", "typ", "width") val inputIdTypeWidthCheck = RxInputMatchGroups(inputIdTypWidthPat, List(InputMatchGroups("""@COUNTRY_CODE char(2),""", List(MatchGroups("""@COUNTRY_CODE char(2)""", List("COUNTRY_CODE", "char", "2")))))) def getIdTypWidth(s: String): (Option[(String, String, Int)], Int) = { val om: Option[Match] = inputIdTypWidthPat.findFirstMatchIn(s) if (om.isDefined) { if (om.get.groupCount == 3) { (Some(om.get.group(1), om.get.group(2), om.get.group(3).toInt), om.get.end) } else (None, 0) } else (None, 0) }