如何删除文本文件中每行的前 x 个字符?
我有一个文本文件,我想删除每行的前 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在任何支持正则表达式的文本编辑器中执行此操作(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.
拿起自己的 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.
如果您只需要执行此操作一次,请在支持列选择的文本编辑器中打开文件,选择要剪切的列,然后将其删除。例如,当您按 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?