如何删除文本文件中每行的前 x 个字符?

发布于 2024-12-21 02:42:57 字数 307 浏览 3 评论 0原文

我有一个文本文件,我想删除每行的前 6 个字符。字符是空格和一些数字。它们是 ascii 字符。这怎么能做到呢?我有一个windows环境。

示例文件:

54863 important text line 1
14247 important text line 2
29751 important text line 3

示例结果:

important text line 1
important text line 2
important text line 3

I have a text file where I want to remove the first 6 characters of every line. The characters are whitespace and some numbers. They are ascii characters. How can this be done? I have a windows environment.

Example file:

54863 important text line 1
14247 important text line 2
29751 important text line 3

Example result:

important text line 1
important text line 2
important text line 3

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

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

发布评论

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

评论(3

转瞬即逝 2024-12-28 02:42:58

您可以在任何支持正则表达式的文本编辑器中执行此操作(notepad++ 是 Windows 且免费)。

用于查找和替换的简单表达式是

^......

Which 将匹配每行的前六个字符。显然你可以用“”替换任何内容。

You could do this in any text-editor that supports regular expressions (notepad++ is windows and its free)

A simple expression for find and replace would be

^......

Which would match the first six character of each line. Obviously you can replace with "" nothing.

十年九夏 2024-12-28 02:42:58

拿起自己的 Notepad++(例如来自 www.portableapps.com),在前六个字符上进行矩形选择,最后按 DEL 。要进行矩形选择,请按住 ALT 并单击鼠标左键进行拖动。

Grab yourself Notepad++ (e.g. from www.portableapps.com), make a rectangular selection over the first six characters end press DEL. To make a rectangular selection hold ALT and drag with left mouse button clicked.

过期以后 2024-12-28 02:42:58

如果您只需要执行此操作一次,请在支持列选择的文本编辑器中打开文件,选择要剪切的列,然后将其删除。例如,当您按 ctrl + alt 时,Notepad++ 会进入列选择模式。

如果您想多次执行此操作,则应该编写一个脚本来为您执行此操作。你能用任何语言编程吗?

If you only need to do this once, open your file in a text editor that supports column selection, select the columns you want to cut, and delete them. For example, Notepad++ enters column selection mode when you press ctrl + alt.

If you want to do this more than once, you should write a script that would do it for you. Can you program in any language?

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