2016-09-23 207 views
0

我想在继续的字幕行前加一个短划线。像这样:在Notepad ++中在特定字幕行的前面和末尾添加字符?

例子(.SRT):

1 
00:00:48,966 --> 00:00:53,720 
Today he was so angry and happy 
at the same time, 

2 
00:00:53,929 --> 00:00:57,683 
he went to the store and bought a 
couple of books. Then the walked home 

3 
00:00:57,849 --> 00:01:01,102 
with joy and jumped in the pool. 

4 
00:00:57,849 --> 00:01:01,102 
One day he was in a bad mood and he 
didn't get happier when he read. 

这样:

1 
00:00:48,966 --> 00:00:53,720 
Today he was so angry and happy 
at the same time- 

2 
00:00:53,929 --> 00:00:57,683 
-he went to the store and bought a 
couple of books. Then the walked home- 

3 
00:00:57,849 --> 00:01:01,102 
-with joy and jumped in the pool. 

4 
00:00:57,849 --> 00:01:01,102 
One day he was in a bad mood and he 
didn't get happier when he read. 

原始字幕是在瑞典。这是斯堪的纳维亚语字幕的标准。

如何用Notepad ++中的正则表达式格式化它?我应该如何编写标签,以及如果字幕在前端和末尾包含斜体标签?

回答

0

你可以使用这个表达式与gm修饰符:

(?:,|([^.?!]<[^>]+>|[^>.?!]))$(\n\n.*\n.*\n) 

使用$1-$2-作为替代。

我使用了一个简单的句子定义。如果有.?!之一,那就算作句子的结尾。虽然这可能不是一个完美的定义,但你只能看句子的结尾。

取决于几个因素(例如,以一行结尾),您可能需要稍微调整一下。


本质上,正则表达式是两部分。

第一部分匹配行尾的三件事之一。如果它匹配逗号,则该逗号将被删除。否则,它看起来是否最后一个字母(如果有标签,在此之前的字母)不是.?!中的任何一个。

第二部分匹配需要短划线之前的所有行。这也有助于确保刚刚匹配的行的末尾后面跟着一个新行(而不是更多文本)。

相关问题