Settings

Theme

Why do regexes use `$` and `^` as line anchors?

buttondown.email

32 points by manuw 2 years ago · 18 comments

Reader

latexr 2 years 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 2 years ago

    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.

    • latexr 2 years 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.

sethammons 2 years ago

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.

lesquivemeau 2 years ago

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

Lex-2008 2 years ago

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

  • em500 2 years ago

    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.

sys_64738 2 years ago

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.

  • em500 2 years ago

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

demondemidi 2 years ago

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

JSR_FDED 2 years ago

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

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection