Notepad++ RegEx replace with Zerofill

隐身守侯 提交于 2019-12-20 04:12:50

问题


I need to replace a list like this:

105164 25
105164 26
105164 29
105496 1
105496 2

To

105164_0025
105164_0026
105164_0029
105496_0001
105496_0002

Something like (\w)([0-9]+) to _$1 but how to do the left zero padding?


回答1:


[ ]([0-9]+) to _$1   --do your first replace
_([0-9])$ to _000$1
_([0-9][0-9])$ to _00$1
_([0-9][0-9][0-9])$ to _0$1

Kind of a cheat method but that's the only way I can think of.




回答2:


You can do in two passes:

first pass:
Find what: (\d+)$
Replace with: _0000$1

second pass:
Find what: _0*(\d{4})$
Replace with: _$1



来源:https://stackoverflow.com/questions/25624498/notepad-regex-replace-with-zerofill

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!