不是一個非常好的辦法做到這一點,但工程對少量套數。我用你的例子中的2150行進行了測試,幾乎立即完成。雖然開始掙扎在100萬行左右。它的工作原理,但它需要時間:
使用搜索和替換在記事本++與搜索模式正則表達式搜索
\b([0-9]{3,5})\b
與0\1
更換和命中Replace all
3倍。
因此,每3-5位數字將被其前面的0代替。當全部替換3次時,確保3位數字填充3個前導零。
同樣不是一個好方法,但對於我的工作......
編輯:剛纔看到它必須自動完成...也許記事本+ +有一些工具來執行搜索和替換爲腳本,但我會把它留給別人;)
又一編輯:我只是忍不住自己我不得不找出它...我用記事本++的宏函數來記錄上述S & R和擡頭,你可以找到你保存宏...
成果是這樣的:
<Macro Key="32" Shift="yes" Alt="yes" Ctrl="no" name="MyUpdater">
<Action sParam="" lParam="0" wParam="0" message="1700" type="3"/>
<Action sParam="\b([0-9]{3,5})\b" lParam="0" wParam="0" message="1601" type="3"/>
<Action sParam="" lParam="2" wParam="0" message="1625" type="3"/>
<Action sParam="0\1" lParam="0" wParam="0" message="1602" type="3"/>
<Action sParam="" lParam="768" wParam="0" message="1702" type="3"/>
<Action sParam="" lParam="1609" wParam="0" message="1701" type="3"/>
<Action sParam="" lParam="0" wParam="0" message="1700" type="3"/>
<Action sParam="\b([0-9]{3,5})\b" lParam="0" wParam="0" message="1601" type="3"/>
<Action sParam="" lParam="2" wParam="0" message="1625" type="3"/>
<Action sParam="0\1" lParam="0" wParam="0" message="1602" type="3"/>
<Action sParam="" lParam="768" wParam="0" message="1702" type="3"/>
<Action sParam="" lParam="1609" wParam="0" message="1701" type="3"/>
<Action sParam="" lParam="0" wParam="0" message="1700" type="3"/>
<Action sParam="\b([0-9]{3,5})\b" lParam="0" wParam="0" message="1601" type="3"/>
<Action sParam="" lParam="2" wParam="0" message="1625" type="3"/>
<Action sParam="0\1" lParam="0" wParam="0" message="1602" type="3"/>
<Action sParam="" lParam="768" wParam="0" message="1702" type="3"/>
<Action sParam="" lParam="1609" wParam="0" message="1701" type="3"/>
</Macro>
Close Notepad ++。 轉到%appdata%\Notepad++\
並打開文件shortcuts.xml
與正常的文本編輯器(記事本+ +將覆蓋它回到正常狀態),並將上面的xml代碼放在那裏(應該已經有一個名爲「Trim Trailing and Save」的宏, ;。只要把它關閉</Macro>
標記下,並將其保存在您打開Notepadd ++現在和菜單欄點擊宏應該有一個叫「MyUpdater」
目前該快捷方式設置爲Alt鍵 + 移 + 空間,但你可以改變它點擊宏 - >編輯快捷方式。
這對我有用,就像這樣,你可以將makro「導出」給其他用戶。
要撤消此操作,您可以搜索\b([0])
並將其替換爲空字符串。注意你必須再次檢查正則表達式!這裏只需打一次Replace就足夠了。
如果有什麼事隨時問:)
這是製表符分隔的文件還是固定的文件? – Squashman
[Notepad ++ RegEx替換爲Zerofill]的可能重複(http://stackoverflow.com/questions/25624498/notepad-regex-replace-with-zerofill) – Toto