利用下文正則表達式,用空字符串替換''
。
(只需使用replace_all)
# '~(?mi-)(?:(?!\A)\G|^@subpackage)[^ \r\n]*\K[ ]+~'
(?xmi-) # Inline 'Expanded, multiline, case insensitive' modifiers
(?:
(?! \A) # Matched before, start from here
\G
| # or,
^@subpackage # '@Subpackage' at bol (remove '^' if not at bol)
)
[^ \r\n]* # Not space or line breaks
\K # Don't include anything from here back in match
[ ]+ # 1 or more spaces
這是一個對所有非斷行空格。
# '~(?mi-)(?:(?!\A)\G|^@subpackage)\S*\K[^\S\r\n]+~'
(?xmi-) # Inline 'Expanded, multiline, case insensitive' modifiers
(?:
(?! \A) # Matched before, start from here
\G
| # or,
^@subpackage # '@Subpackage' at bol (remove '^' if not at bol)
)
\S* # 0 or more, Not whitespace
\K # Don't include anything from here back in match
[^\S\r\n]+ # 1 or more non-linebreak whitespaces
來源
2014-10-09 15:44:22
sln
難以理解:( – vks 2014-10-09 15:32:24
所以,你要'部分文字Stuff'成爲'SomeWordStuff'? – Grice 2014-10-09 15:33:57
是'@ subpackage'始終在該行的開始? – 2014-10-09 15:40:29