我有一些SRT数据在每个句子中间用\ r和\ n标签作为换行符返回。我如何才能在文本/句子中间找到\ r和\ n标签,而不是其他表示其他换行符的标签。查找某些/特定的换行符而忽略其他
示例源:
18
00:00:50,040 --> 00:00:51,890
All the women gather
at the hair salon,
19
00:00:52,080 --> 00:00:56,210
all the mothers and daughters
and they dye their hair orange.
所需的输出:
18
00:00:50,040 --> 00:00:51,890
All the women gather at the hair salon,
19
00:00:52,080 --> 00:00:56,210
all the mothers and daughters and they dye their hair orange.
我在正则表达式绝对的废话,但我最好的猜测(无济于事)是像
变种reg =/[\ d \ r] [a-zA-z0-9 \ s +] + [\ r]/
然后再分割()以去除其中一个值中间的\ r。我相信这甚至没有接近正确的方式,所以... stackoverflow! :)
http://regexpal.com/是你的朋友,以及! –
如果句子是'有橙色头发的女人',怎么办?你如何区分'3'后面的换行符与段号后面的换行符(或者其他什么)?我们可以假设每个块本身总是一行(?)数字,然后是单独一行上的00:00:52,080 - > 00:00:56,210位,然后是一行或多行文本(这就是需要删除换行符的位置),然后是空行? – nnnnnn
确切!这就是为什么它如此棘手。但是,是的,我们可以假设提示线(即“18”)将始终位于其自己的线上,并且时间范围始终位于一条线上。可能在两行上的唯一内容就是文本。这些帮助有用??? – Jason