【发布时间】:2016-11-06 02:47:04
【问题描述】:
我有一个电影的字幕文件,如下所示:
2
00:00:44,687 --> 00:00:46,513
Let's begin.
3
00:01:01,115 --> 00:01:02,975
Very good.
4
00:01:05,965 --> 00:01:08,110
What was your wife's name?
5
00:01:08,943 --> 00:01:12,366
- Mary.
- Mary, alright.
6
00:01:15,665 --> 00:01:18,938
He seeks the spirit
of Mary Browning.
7
00:01:20,446 --> 00:01:24,665
Mary, we invite you
into our circle.
8
00:01:28,776 --> 00:01:32,834
Mary Browning,
we invite you into our circle.
....
现在我只想匹配实际的字幕文本内容,例如,
- Mary.
- Mary, alright.
或者
He seeks the spirit
of Mary Browning.
包括它们可能包含的特殊字符、数字和/或换行符。但是我不想匹配时间字符串和序列号。
所以基本上我想将所有包含数字和特殊字符的行只与字母匹配,而不是数字和特殊字符,它们单独存在于其他行,如时间字符串和序列号。
如何匹配并添加标签 <font color="#FFFF00">[subtitle text any...]</font> 到我匹配的每个字幕与 Regex 的帮助?
意思如下:
<font color="#FFFF00">He seeks the spirit
of Mary Browning.</font>
【问题讨论】:
-
你使用什么语言?
-
没有语言,只是字幕语法,只是普通的 .srt 文件和 Geany 编辑器。
-
你使用的语言... C#, php, javascript, ... 需要使用什么风格的正则表达式?
-
不,它只是简单的字幕文本格式,既不是 php,也不是 javascript 或其他任何东西。到目前为止,我认为 PCRE 工作正常。
标签: regex replace tags match srt