我有一段文本,每行末尾都有时间,我想保留时间并在时间后添加新行,同时用 ; 分隔行,以便能够在 excel 中导入 CSV 文件。当时间在前面时,我之前的问题得到了一些帮助,但我尝试过移动表达式,\R(?!\d\d:\d\d|\z)
但没有成功。
正文如下:
Nån Annan Nu - Molly Sandén
Nån Annan Nu
Molly Sandén
22:33
Lay All Your Love On Me - Abba
Lay All Your Love On Me
Abba
14:21
What's Love Got To Do With It - Kygo and Tina Turner
What's Love Got To Do With It
Kygo and Tina Turner
12:47
我希望结果是
Nån Annan Nu - Molly Sandén;Nån Annan Nu;Molly Sandén;22:33
Lay All Your Love On Me - Abba;Lay All Your Love On Me;Abba;14:21
What's Love Got To Do With It - Kygo and Tina Turner;What's Love Got To Do With It;Kygo and Tina Turner;12:47
希望有人能帮助解决这个问题,并解释搜索和替换表达式功能的工作原理,或者帮我提供链接,以便我可以阅读有关此内容的内容。
答案1
- Ctrl+H
- 找什么:
(?<!\d\d:\d\d)\R
- 用。。。来代替:
;
- 打钩 环绕
- 选择 正则表达式
- Replace all
解释:
(?<! # negative lookbehind, make sure we haven't before:
\d\d:\d\d # 2 digit-colon-2 digit
) # end of lookbehind
\R # any kind of linebreak