在 Notepad++ 字符的第一个实例处插入回车 return
Insert carriage return at first instance of character in Notepad++
我有一个包含数百行的文本文件。每行包含以下信息:
software.cisco.com , Added by IT, ZZ 6584
我想做的是在第一个逗号所在的位置插入回车 return。我可以使用 search/replace 并使用 /n 表达式来做到这一点。问题是它插入了 carriage return 两次,给我留下了 3 行。我试图仅在第一个逗号处插入回车 return 并保留其余行。
之前:
software.cisco.com , Added by IT, ZZ 6584
之后:
software.cisco.com
#Added by IT, ZZ 6584
使用
^(.*?),\s*
替换:\n#
.
见proof。
解释
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
.*? any character except \n (0 or more times
(matching the least amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
, ','
--------------------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
我有一个包含数百行的文本文件。每行包含以下信息:
software.cisco.com , Added by IT, ZZ 6584
我想做的是在第一个逗号所在的位置插入回车 return。我可以使用 search/replace 并使用 /n 表达式来做到这一点。问题是它插入了 carriage return 两次,给我留下了 3 行。我试图仅在第一个逗号处插入回车 return 并保留其余行。
之前:
software.cisco.com , Added by IT, ZZ 6584
之后:
software.cisco.com
#Added by IT, ZZ 6584
使用
^(.*?),\s*
替换:\n#
.
见proof。
解释
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
.*? any character except \n (0 or more times
(matching the least amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
, ','
--------------------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))