在 Notepad++ 中使用正则表达式的行号? [英] Line's number using regex in Notepad++?

查看:58
本文介绍了在 Notepad++ 中使用正则表达式的行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Notepad++ 中使用正则表达式获取行号;

Is it possible to get the line's number using regex in Notepad++;

我想做的是替换:

line1
line2
line3
etc..

1-line1
2-line2
3-line3
etc..

推荐答案

Notepad++ 可以通过使用 TextFX 插件来做到这一点.选择行,然后从菜单栏中选择 TextFX->TextFX Tools->Insert Line Numbers.

Notepad++ can do that by using the TextFX plugin. Select the lines and then select TextFX->TextFX Tools->Insert Line Numbers from the menu bar.

这会将行号添加到带有前导零的 8 个位置.要以您的问题中描述的形式获取它们,您可以使用带有以下值的正则表达式替换:

This will add line-numbers padded to 8 places with leading zeros. To get them in the form described in your question, you can use a regex-replace with these values:

搜索:^0+([0-9]+)\s

替换为:line\1-

这篇关于在 Notepad++ 中使用正则表达式的行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆