更新时间:2023-02-17 23:14:00
你的模式没有捕获组,因此 \1
是一个空字符串.改用 $0
来引用整个匹配项:
Your pattern has no capturing group, hence \1
is an empty string. Use $0
instead to refer to the whole match:
查找内容:[^:{})]$
替换为:$0;
然而,在某些边缘情况下它可能会失败([^:{})]$
模式匹配除 :
、{
之外的任何字符code>、}
和 )
,因此在行结束前至少需要 1 个字符),也许,您***在此处使用负向后视:
However, it might fail in some edge cases (the [^:{})]$
pattern matches any char other than :
, {
, }
and )
, so requires at least 1 char before a line end), perhaps, you should better use a negative lookbehind here:
查找内容:$(?<![:{})])
替换为:;
$(?<![:{})])
模式匹配行尾(使用 $
),然后是 (?<![:{})])
负向后视确保没有 :
、{
、}
或 >)
紧接在当前位置的左侧.
The $(?<![:{})])
pattern matches the end of line (with $
) and then the (?<![:{})])
negative lookbehind makes sure that there is no :
, {
, }
or )
immediately to the left of the current location.