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.
Why do regexes use `$` and `^` as line anchors? (2024)
11–20 of 48 posts
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#12That's how I remembered them anyhow
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#13Some of the older Baudot code ones actually had a £ but not a $ symbol. After we'd decided that 5-key chorded keyboards were not the way forwards, and made QWERTY ones, we still had this encoding to deal with: https://hackaday.com/2015/09/27/demonstrating-baudot-code/
The US version then put the $ sign on what we'd today call ^D, which originally was ENQ (a code that still exists in ascii today, and was sort of the pre-TCP version of a SYN).
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#14Of course I was 100% incorrect as $ is in fact the end-of-line marker so now I just remember that "it's the opposite"!
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#15Re: Why do regexes use `$` and `^` as line anchors? (2024)
#16I mean. Fair enough. I guess.
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#17Re: Why do regexes use `$` and `^` as line anchors? (2024)
#18I remember when learning regexes, struggling to remember which of ^ and $ were the beginning or end of the line. I know that my (and many other) shells used $ as the prompt symbol - i.e. at the beginning of what I was to type in the terminal. It being at the beginning of that line made it easy for me to remember that it also marks the beginning of regexes. Of course I was 100% incorrect as $ is in fact the end-of-lin…
"No, the other left..."
For me it was easier to remember what ^ was, as it looks like a pointer of sorts, so felt natural it would be the beginning. Like how a string variable points to the first character.
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#19I remember when learning regexes, struggling to remember which of ^ and $ were the beginning or end of the line. I know that my (and many other) shells used $ as the prompt symbol - i.e. at the beginning of what I was to type in the terminal. It being at the beginning of that line made it easy for me to remember that it also marks the beginning of regexes. Of course I was 100% incorrect as $ is in fact the end-of-lin…
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#20I remember when learning regexes, struggling to remember which of ^ and $ were the beginning or end of the line. I know that my (and many other) shells used $ as the prompt symbol - i.e. at the beginning of what I was to type in the terminal. It being at the beginning of that line made it easy for me to remember that it also marks the beginning of regexes. Of course I was 100% incorrect as $ is in fact the end-of-lin…
Trying to consciously think about the gut-feeling that makes me remember this, all I can come up with is that $ feels "heavier" than ^, which just leads it to naturally feel like the end of a line. Perhaps its verticalness makes it feel like the vertical blinking cursor, and that's what this gut-feeling is really about? I'm not sure, the mind is a mystery sometimes haha.