Live data from Hacker News

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

buttondown.com

1–10 of 48 posts

Re: Why do regexes use `$` and `^` as line anchors? (2024)

#5
> Thompson and Lampson are still alive and we can just ask them. I just sent emails to both, I'll update this if I get an answer!

This is one of the great things about this age. The barrier of reaching out to some person and asking them a question has never been lower. I've done this for RFCs, I've done this for questions about blog posts I've discovered here on HN. I've gotten lots of responses from people and it's always been illuminating to me.

Re: Why do regexes use `$` and `^` as line anchors? (2024)

#7

> $ is so important in business that every typewriter has one I actually had a typewriter without one. I would simulate it with S / which was not very satisfactory but generally understandable in context.

Was it a US typewriter? This peso symbol is very important in business in the US and Latin America but not, for example, England, Ireland, India, Finland, or Sweden.

Re: Why do regexes use `$` and `^` as line anchors? (2024)

#9
post #6

My AZERTY keyboard conveniently has them side by side (^ left of $). Could it be a similar reason?

AZERTY is primarily a French keyboard layout, to my knowledge.

The standard QWERTY layout for the number key row is `/~, 1/!, 2/@, 3/#, 4/$, 5/%, 6/^, 7/&, 8/*, 9/(, 0/), -/_, =/+. I don't know how far back the mapping of shift keys for the numbers go, but I'd be shocked if there was any around the 1960s or 1970s that put them like your AZERTY keyboard.

Post reply on HN