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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: A more ergonomic sed using JavaScript regexes

1 点作者 ariabuckles将近 6 年前
I love `sed`, but specifying in-place replacement across linux&#x2F;mac is challenging, and I find both the regular expression options hard to remember the exact syntax for.<p>So I built a small wrapper around String.prototype.replace to give the syntax and power of javascript regular expressions (and, optionally, javascript functions):<p>https:&#x2F;&#x2F;github.com&#x2F;ariabuckles&#x2F;jsed<p>Or to install:<p><pre><code> npm install -g @ariabuckles&#x2F;jsed </code></pre> Some examples:<p>You can use it pretty similarly to `sed`:<p><pre><code> echo &quot;this is a test&quot; | jsed &#x27;\w+&#x27; &#x27;word:$&amp;&#x27; &gt; word:this word:is word:a word:test </code></pre> Or you can use it more like javascript when needed:<p><pre><code> echo &quot;1 2 3 4&quot; | jsed &#x27;&#x2F;\d+&#x2F;g&#x27; &#x27;(num) =&gt; num%2 == 0 ? &quot;even&quot; : &quot;odd&quot;&#x27;</code></pre>

暂无评论

暂无评论