from Hacker News

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

by manuw on 3/26/24, 8:38 AM with 14 comments

  • by latexr on 3/26/24, 2:01 PM

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

  • by sethammons on 3/26/24, 10:25 AM

    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.
  • by lesquivemeau on 3/26/24, 10:34 AM

    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
  • by Lex-2008 on 3/26/24, 10:58 AM

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

  • by sys_64738 on 3/26/24, 11:59 AM

    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.
  • by demondemidi on 3/26/24, 1:37 PM

    The article is all speculation and not fact. Sorry OP but this is just garbage content.
  • by JSR_FDED on 3/26/24, 10:43 AM

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