TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

32 点作者 manuw大约 1 年前

7 条评论

latexr大约 1 年前
&gt; So there you have it, an explanation for the regex anchors that kinda makes sense.<p>That’s not an explanation, it’s <i>speculation</i>. The whole article was guess work and you picked something that sounded plausible. Ken Thompson is alive, why not ask and confirm? <i>Then</i> you could say you have an explanation.
评论 #39833551 未加载
sethammons大约 1 年前
Ken is still around; did the author reach out and ask? Could be a similar story to Rob Pike and the Go date format: he didn&#x27;t think about it and just picked the first thing that came to mind.
评论 #39826186 未加载
lesquivemeau大约 1 年前
This always made sense to me because they are next to each other on an AZERTY keyboard: tab,A,Z,E,R,T,Y,U,I,O,P,^,$,return
评论 #39826188 未加载
Lex-2008大约 1 年前
Not sure about $ sign, but ^ probably comes from ADM-3A: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;ADM-3A#Legacy" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;ADM-3A#Legacy</a><p>And here is a photo of its keyboard: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;toresbe&#x2F;status&#x2F;1756800589340549609&#x2F;photo&#x2F;2" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;toresbe&#x2F;status&#x2F;1756800589340549609&#x2F;photo...</a>
评论 #39827565 未加载
sys_64738大约 1 年前
They&#x27;re because that&#x27;s what Bill Joy used in vi back in 1979 to move to the beginning and end of a line. It made sense to use them for regex too.
评论 #39827548 未加载
demondemidi大约 1 年前
The article is all speculation and not fact. Sorry OP but this is just garbage content.
JSR_FDED大约 1 年前
This article should be considered the $ word on this topic.