Hacker News new | past | comments | ask | show | jobs | submit login
[flagged] Why do regexes use `$` and `^` as line anchors? (buttondown.email/hillelwayne)
32 points by manuw on March 26, 2024 | hide | past | favorite | 14 comments



> 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.


Explanations 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.


> 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.


Ken 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.


The article devolves from fact to fiction/guesswork rather quickly.


This 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


Another roman car like effect.


Not sure about $ sign, but ^ probably comes from ADM-3A: https://en.wikipedia.org/wiki/ADM-3A#Legacy

And here is a photo of its keyboard: https://twitter.com/toresbe/status/1756800589340549609/photo...


Per 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.


They'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.


Per the article, these anchors appear in Ken Thompson's port of the QED text editor, which dates back to 1970.


The article is all speculation and not fact. Sorry OP but this is just garbage content.


[flagged]


I clicked this link because the question is interesting. Yes the answer won't change my life, or even make me more money, but it got me curious. That's why I don't think your response is helpful or insightful.


This article should be considered the $ word on this topic.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: