在 NotePad++ 中,如何用逗号连接所有以缩进(Tab 或 4 个空格)开头的行
analyse
analysed
analyser
analysers
analyses
analysing
analysis
analyst
analysts
analytic
analytical
approach
approachable
approached
approaches
approaching
unapproachable
像是
analyse
'analysed','analyser','analysers','analyses','analysing','analysis','analyst','analysts','analytic','analytical'
approach
'approachable','approached','approaches','approaching','unapproachable'
答案1
- Ctrl+H
- 找什么:
\h+(\w+)(\R?)(\w)?
- 用。。。来代替:
'$1'(?3$2:,)$3
- 查看 环绕
- 查看 正则表达式
- Replace all
解释:
\h+ # 1 or more horizontal spaces
(\w+) # group 1, 1 or more word characters
(\R?) # group 2, any kind of linebreak, optionnal
(\w)? # group 3, optionnal, a word character
替代品:
' # single quote
$1 # content of group 1
' # single quote
(?3 # if group 3 exists (i.e. there is a word chracter at the beginning of next line)
$2 # add content of group 2, the linebreak
: # else
, # add a comma
) # endif
$3 # content of group 3
截图(之前):
截图(之后):