我正在尝试从以特定模式开头的行中删除空格。所有其他线路都不会受到影响。 例如
ODBC; DSN=Orac lePacket1; DBA=W; ;APA=R
应该是
ODBC;DSN=Oracle;DBA=W;APA=R
但
Table: LPR_MONTH_VRNM_COM
应保持
Table: LPR_MONTH_VRNM_COM
我虽然解决方案非常简单,但Notepad Plus中的正则表达式并不与我合作。
答案 0 :(得分:1)
您可以使用此模式而不替换任何内容:
(?:\G(?!^)|^(?!Table:))[^ \n\r]*\K +
模式细节:
(?: # Two possible branches:
# A branch contiguous to the precedent match:
\G # anchor for the end of the last match or the start of the string
(?!^) # not at the start of the string (or the line)
| # OR
^(?!Table:) # A branch at the start of the line but not followed by "Table:"
)
# Then we reach the next space:
[^ \n\r]* # all characters that are not a space or a newline
\K # removes all that have been matched on the left from the result
[ ]+ # then only spaces will be removed.