gpt4 book ai didi

regex - 使用正则表达式解析字幕(srt)

转载 作者:行者123 更新时间:2023-12-03 21:33:34 31 4
gpt4 key购买 nike

我想用正则表达式解析字幕。但不匹配多行文本。

正则表达式代码:

(?<order>(\d+))\n(?<start>([\d:,]+))[\s-{2}\>]+(?<end>([\d:,]+))\n(?<text>(.+|\n))

https://regex101.com/r/jV9oV2/2

最佳答案

(?<order>\d+)\n(?<start>[\d:,]+)\s+-{2}\>\s+(?<end>[\d:,]+)\n(?<text>[\s\S]*?(?=\n{2}|$))

您可以通过这种方式修改正则表达式以获取 text .见演示。

https://regex101.com/r/jV9oV2/3

关于regex - 使用正则表达式解析字幕(srt),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30882612/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com