提问人:Hank K 提问时间:9/22/2022 最后编辑:blhsingHank K 更新时间:9/23/2022 访问量:45
当仅在带有正则表达式的时间码之间的单行上时,需要删除连字符
Need to REMOVE hyphen when only on SINGLE line between time codes with regex
问:
当仅在时间码之间的单行上时,需要删除连字符。因此,在下面的情况下,只想删除 #24 上的连字符。仅供参考:该行可以结束许多不同的字符。
19
00:07:03,089 --> 00:07:04,007
- Really?
- Mm-hmm.
24
00:03:01,848 --> 00:03:04,893
- How adorable.
48
00:02:53,798 --> 00:02:54,758
[clears throat]
49
00:02:57,552 --> 00:02:59,971
- [clears throat] Phil.
- What can I get you?
以下是我认为可能有效的[不抽雪茄]:
Find: ^(- )(?=.*\r?\n([A-Za-z\[]))
Replace: - $1
正确的最终结果如下,在 #24 上删除了连字符
19
00:07:03,089 --> 00:07:04,007
- Really?
- Mm-hmm.
24
00:03:01,848 --> 00:03:04,893
How adorable. <<<<<---- hyphen removed
48
00:02:53,798 --> 00:02:54,758
[clears throat]
49
00:02:57,552 --> 00:02:59,971
- [clears throat] Phil.
- What can I get you?
提前致谢,汉克
答:
1赞
blhsing
9/22/2022
#1
您可以使用否定前瞻模式来匹配以连字符开头且后面不跟以连字符开头的另一行之前的行,捕获该行并在匹配中包含连字符,然后将匹配项替换为捕获但不带连字符的内容:
替代:
^((?!- )[^\n]*\n)- (?![^\n]*\n- )
跟:
$1
评论