Parse subtitle file using regex C#

前端 未结 5 480
南笙
南笙 2021-01-26 19:49

I need to find the number, the in and out timecode points and all lines of the text.

9
00:09:48,347 --> 00:09:52,818
- Let\'s see... what else she\'s got?
-          


        
5条回答
  •  星月不相逢
    2021-01-26 20:07

    I used this regex in my Ruby parser:

    slines.scan(/(^[0-9]+)\r?\n(.*? --> .*?)\r?\n(.*?)(?=^[0-9]+\r?\n|\s+\Z)/im).map{|z| [z[0],[z[1],z[2].strip]]}
    

    where "slines" is the whole subtitle file read into memory.

提交回复
热议问题