我有一个srt文件
1 00:00:07,000 --> 00:00:09,000 Time to amaze the world.. create by Hazy 2 00:00:11,000 --> 00:00:12,200 show them 3 00:00:15,000 --> 00:00:16,500 an impossible feat
我想获得文字内容
Time to amaze the world.. create by Hazy, show them, an impossible feat
我的正则表达式:
string[] souceSrt = Regex.Split(inputText.Text, @"\n*\d+\n\d\d:\d\d:\d\d,\d\d\d --> \d\d:\d\d:\d\d,\d\d\d\n");
但它不起作用.我该怎么办??
你的方法并不坏,我认为你的模式因为换行符(可能是CRLF)而不起作用:
(?:\r?\n)*\d+\r?\n\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3}\r?\n
请注意,您的第一种方法比搜索包含字母的所有行更安全(想象一个字符说"你多大了?")