在不同的行中製作連續的編號列表

在不同的行中製作連續的編號列表

我在 {1} 這是測試資料 {2 } 這是另一個資料有一些資料。注意錯誤 {3} This is one more data { 4} another space error before number 給出的兩個後面的空格

我想讓所有內容都在自己的行中,格式正確為 {1},即數字之前或之後沒有空格

我需要一個用於 Notepad++ 的正規表示式

謝謝

答案1

  • Ctrl+H
  • 找什麼:{\h*(\d+)\h*}
  • 替換為:\n{$1}\r\n{$1}取決於平台
  • 查看 相符
  • 查看 環繞
  • 查看 正規表示式
  • 取消選取 . matches newline
  • Replace all

解釋:

{           # open brace
\h*         # 0 or more horizontal spaces
(\d+)       # group 1, 1 or more digits
\h*         # 0 or more horizontal spaces
}           # close brace

替代品:

\n          # linefeed, you can use \r\n for Windows EOL
{$1}        # content of group 1 (i.e. the digits) surrounded by braces

截圖(之前):

在此輸入影像描述

截圖(之後):

在此輸入影像描述

相關內容