
我有一個非常長的文字檔案(大約 15k 行)。它只包含數字(6 個數字,以空格分隔)。我只對每行的前三個數字感興趣。我嘗試過選擇列模式並將其向下拖動,但是速度非常慢,而且我有幾個文件需要處理。
我也嘗試過“開始/結束選擇”技巧,但它似乎不適用於列。
有沒有辦法自動選擇文字檔案中的最後三列數字?一種方法是選擇指定列中的所有行。有可能嗎?
答案1
嘗試這個:
- 按CTRL+Home將鍵入遊標移至文件頂部。
- 現在,使用捲軸快速捲動到文件底部,而無需更改打字遊標的位置。您可以拖曳捲軸的滑桿部分快速到達文件底部。真的很快。
- 將滑鼠指標移到最後一行的第三個數字之後,按住Alt+Shift並點擊。
答對了!
答案2
這可以使用以下正規表示式來完成,假設您的數字只是數字(即沒有逗號,小數點):
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
1111 2222 3333 4444 5555 6666
CTRL-H 轉到尋找和替換
Find what: .*\s(\d+\s\d+\s\d+)$
Replace with: \1
Search Mode: Regular expression
find 正規表示式的解釋:
.* = match anything, repeating
\s = match single whitespace
( = start capture group
\d+ = match one or more numerals
\s = match single whitespace
\d+ = match one or more numerals
\s = match single whitespace
\d+ = match one or more numerals
) = end capture group
$ = match end of line
以及替換框:
\1 = capture group 1 from the prior regex match (everything matched between the ( and the ))
這需要幾秒鐘的時間來替換,並留下最後三列數字,即。
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
4444 5555 6666
NPP更換盒截圖: