I 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…
Why do regexes use `$` and `^` as line anchors? (2024)
21–30 of 48 posts
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#22I 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)
#23I 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…
Idk why anyone would ever "learn regex's" without the use of a look up table. It's not like timestables where having it memorized will really accelerate other aspects of life. Knowing what ^ does by memory will almost never benefit you.
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#24I 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)
#25> $ 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.
It's also very interesting to me that [1] mentions it can have one or two bars but in the list above the double-barred version is not only not in unicode but refers specifically to the cifrão[2].
I guess the TLDR is currency stuff is confusing and nonstandard more often than not.
[0] https://en.wikipedia.org/wiki/Currency_symbol#List_of_curren...
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#26Re: Why do regexes use `$` and `^` as line anchors? (2024)
#27Earlier quoted context omitted.
Idk why anyone would ever "learn regex's" without the use of a look up table. It's not like timestables where having it memorized will really accelerate other aspects of life. Knowing what ^ does by memory will almost never benefit you.
It does come in handy if you search for stuff with regular expressions a lot!
Start with . and .*, then add additional stuff as you get comfortable
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#28Earlier quoted context omitted.
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.
I know this symbol is used for pesos, but when 24 countries refer to it as "dollar"[0] compared to 7 for "peso" it seems fair to call it a dollar symbol? Not to mention that it's referred to as "dollar" in unicode. It's also very interesting to me that [1] mentions it can have one or two bars but in the list above the double-barred version is not only not in unicode but refers specifically to the cifrão[2]. I guess t…
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#29Everything starts with someone pointing at something. Everything ends with dollars. That's how I remembered them anyhow
Re: Why do regexes use `$` and `^` as line anchors? (2024)
#30My 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.