查找行中除空行外的任何最后一个字符
find any last character in line except empty lines
我需要找到行中的任何最后一个字符,然后添加额外的文本(例如“单词”),但不将此规则应用于空行(行中没有字符)。
我的表达式 ([^\n])$
也适用于空行。
使用
(\S[^\S\n]*)
替换为 word
。参见 proof。
说明
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
\S non-whitespace (all but \n, \r, \t, \f,
and " ")
--------------------------------------------------------------------------------
[^\S\n]* any character except: non-whitespace
(all but \n, \r, \t, \f, and " "), '\n'
(newline) (0 or more times (matching the
most amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
string
我需要找到行中的任何最后一个字符,然后添加额外的文本(例如“单词”),但不将此规则应用于空行(行中没有字符)。
我的表达式 ([^\n])$
也适用于空行。
使用
(\S[^\S\n]*)
替换为 word
。参见 proof。
说明
--------------------------------------------------------------------------------
( group and capture to :
--------------------------------------------------------------------------------
\S non-whitespace (all but \n, \r, \t, \f,
and " ")
--------------------------------------------------------------------------------
[^\S\n]* any character except: non-whitespace
(all but \n, \r, \t, \f, and " "), '\n'
(newline) (0 or more times (matching the
most amount possible))
--------------------------------------------------------------------------------
) end of
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
string