我使用 Notepad++ v8.1.1。
如何找到特定段并仅从该段中删除所有空格和制表符?
例如,我想找到所有“EQD”行并从这些行中删除所有空格和制表符。
样本数据:
EQD+CN+ZMLU XXXXXXX+45GP+++5
NAD+CA+ZMLU:172:ZZZ
LOC+147+0260808::5
FTX+AAA+++ALUMINUM ARTICLES
MEA+WT++KGM:16549
LOC+9+DOHAI:139:6
LOC+11+USSAV:139:6
RFF+BM:1
EQD+CN+ZMLU XXXXXXX+45GP+++5
NAD+CA+ZMLU:172:ZZZ
LOC+147+0260202::5
FTX+AAA+++ALCOHOLIC BEVERAGES
MEA+WT++KGM:27797
LOC+9+JMKIN:139:6
LOC+11+USSAV:139:6
RFF+BM:1
EQD+CN+ZMLUXXXXXXX+45GP+++5
NAD+CA+ZMLU:172:ZZZ
答案1
答案2
这是递归正则表达式的工作:
- Ctrl+H
- 找什么:
(?:^EQD\b|\G(?!^))\S*\K\h+
- 用。。。来代替:
LEAVE EMPTY
- 查看 相符
- 查看 环绕
- 查看 正则表达式
- Replace all
解释:
(?: # non capture group
^ # beginning of line
EQD # literally EQD
\b # word boundary mandatory if you don't want to match EQDXX
| # OR
\G # restart from last match position
(?!^) # not at the beginning of line
) # end group
\S* # 0 or more non space character
\K # forget all we have seen until this position
\h+ # 1 or more horizontal spaces (white space or tab)
截图(之前):
截图(之后):