我想更改此
@author(
line 1
line 2
line 3
)
使用RegEx进行以下操作。
@author(
#line 1
#line 2
#line 3
)
我可以像这样^@author\([^]]+\n\)
来查询块,如何在每行的前面放置#号?
对于PCRE(PHP)正则表达式引擎,可以使用正则表达式
^([^)@].*)
正则表达式正在执行以下操作:
^ # match beginning of line
( # begin capture group 1
[^)@] # match a character other than ')' and ']'
.* # match 0+ chars to the end of the line
) # end capture group 1
假设您使用的是基于PCRE的正则表达式环境,则可以搜索
(@author\(\n|\G(?!\A).*+\n(?!\)))
并将匹配项替换为
$1#
。请参见this expression at regex101.com的说明。