仅在特定行#(REGEX)上替换一个单词

发布于 2025-02-13 20:26:52 字数 128 浏览 1 评论 0原文

在一个大文件中,我需要仅在特定行上替换一个单词。说,在第25、55、181、1448行上,大约2000次。

我开始使用“ to”行并替换单词手动进行操作。即使我必须更改每个实例的值,是否有一种方法可以自动进行操作?它仍然会更快。

Within a large file I need to replace one word only on specific lines. Say, on line 25, 55, 181, 1448, and so forth about 2000 times.

I started doing it manually using "go to" line and replacing the word. Is there a way to do it automatically, even if I have to change the value for every instance? It will still be faster.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠栀 2025-02-20 20:26:53

也许您可以尝试这样的事情:

\A(?:^.*$\n){5}\K^.*$

其中5是以前的行。所以5表示您想获得第6行。

工作示例:
https://regex101.com/r/qudon0/1

Maybe you can try something like this:

\A(?:^.*$\n){5}\K^.*$

Where 5 are the previous lines. So 5 means you want to get line number 6.

Working Example:
https://regex101.com/r/QuDon0/1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文