Why does the string "^" and the end of the string "$" begin?

I never remember if ^ matches the beginning of a line and $ matches the end or vice versa. A good mnemonics would be that the $ sign always comes before the price, so it matches the beginning of the line - unfortunately, it's the other way around.

So, is there a reason why these two characters were chosen to start and end the line?

+7
source share
5 answers

One mnemonics: at the auction, bidders begin to lift their oars. The price of $ set at the end.

+6
source

I remember ^ as: He indicates where he came from, i.e. previous line, so it should be at the beginning.

+1
source

The value $ is used to indicate the end of a line in very early editions, such as ed. It was probably chosen because at that time it was the last unused character on the keyboard :-)

+1
source

This is probably due to the relative position of these two characters on the QWERTY keyboard: '^' in the first position (beginning of line) and '$' after (end of line).

EDIT: I feel bad, this is true only on the French keyboard ( AZERTY ). It provides mnemonics for the user of AZERTY, but not an explanation.

0
source

\A and \Z do roughly the same thing, except that they are slightly different from ^ / $ with respect to the newline characters.

So, if you remember this, and also remember that ^ looks most like A and $ looks most like Z , which can be quite mnemonic.

0
source

All Articles