我使用的是notepad ++和RegEx。
我有一个SRT文件,我想添加三个问号“???”每当第一行的三个字符也是三个问题标记“???”。但是,如果下一行为空,我只希望这样做。但是,如果下一行不是空白,那么我想添加???在下一行结束之后。
例如,这就是我所拥有的。
14
01:04:21,406 --> 01:04:24,887
??? Face I'd never see again
15
01:04:24,885 --> 01:04:27,638
??? It's a shame to awake
in a world of pain
现在我想添加???像这样两条线。
14
01:04:21,406 --> 01:04:24,887
??? Face I'd never see again ???
15
01:04:24,885 --> 01:04:27,638
??? It's a shame to awake
in a world of pain ???
答案 0 :(得分:1)
Notepad ++过去常常遇到多行匹配问题,但据说当前的版本更好地支持Perl风格的正则表达式。我没有安装Notepad ++,但如果它的正则表达式引擎正常工作,那么以下正则表达式可以解决您的问题:
搜索(?s)^(\?{3}.*?(?=\r?\n\r?\n|\z))
并替换为\1???
。
<强>解释强>
(?s) # Turn on dot-matches-all mode
^ # Match start of line
( # Match and capture (group 1)
\?{3} # Three question marks
.*? # Any number of characters, as few as possible
(?= # until the following regex can be matched at the current position:
\r?\n\r?\n # Either two newlines in a row
| # or
\z # the end of the file
) # End of lookahead assertion
) # End of capturing group 1