Get the latest tech news

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


A history that will satisfy nobody.

Last week I fell into a bit of a rabbit hole: why do regular expressions use$ and^ as line anchors? This talk brings up that they first appeared in Ken Thompson's port of the QED text editor. QED was the precursor to ed, which was instrumental in popularizing regexes, so a lot of its design choices stuck.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of regexes

regexes

Photo of line anchors

line anchors

Related news:

News photo

Bad Apple with Regex in Vim