6 ms·
Why do regexes use `$` and `^` as line anchors?
- deleted 2y ago[deleted]
- sethammons 2y agoKen is still around; did the author reach out and ask? Could be a similar story to Rob Pike and the Go date format: he didn't think about it and just picked the first thing that came to mind.
- benrapscallion 2y agoThe article devolves from fact to fiction/guesswork rather quickly.
- ijijijjij 2y ago[flagged]
- lesquivemeau 2y agoThis always made sense to me because they are next to each other on an AZERTY keyboard: tab,A,Z,E,R,T,Y,U,I,O,P,^,$,return
- agumonkey 2y agoAnother roman car like effect.
- JSR_FDED 2y agoThis article should be considered the $ word on this topic.
- Lex-2008 2y agoNot sure about $ sign, but ^ probably comes from ADM-3A: https://en.wikipedia.org/wiki/ADM-3A#Legacy https://en.wikipedia.org/wiki/ADM-3A#Legacy And here is a photo of its keyboard: https://twitter.com/toresbe/status/1756800589340549609/photo/2 https://twitter.com/toresbe/status/1756800589340549609/photo...
- em500 2y agoPer the article, these anchors appear in Ken Thompson's port of the QED text editor which dates back to 1970, years before even the ADM-1 terminal.
- sys_64738 2y agoThey're because that's what Bill Joy used in vi back in 1979 to move to the beginning and end of a line. It made sense to use them for regex too.
- em500 2y agoPer the article, these anchors appear in Ken Thompson's port of the QED text editor, which dates back to 1970.
- demondemidi 2y agoThe article is all speculation and not fact. Sorry OP but this is just garbage content.
- latexr 2y ago> So there you have it, an explanation for the regex anchors that kinda makes sense. That’s not an explanation, it’s speculation. The whole article was guess work and you picked something that sounded plausible. Ken Thompson is alive, why not ask and confirm? Then you could say you have an explanation.
- bitshiftfaced 2y agoExplanations and speculation: are they mutually exclusive? I'd say an answer from Ken Thompson would be a definitive explanation that might disprove the author's explanation, but that doesn't mean it's not an explanation.
- deleted 2y ago[deleted]
- latexr 2y ago> Explanations and speculation: are they mutually exclusive? Yes. You only need to speculate when you don’t have a firm explanation. > disprove the author's explanation Speculation is “the forming of a theory or conjecture without firm evidence”, which is what the author is doing. They’re not explaining, they’re guessing at a reason.