我有一个以下格式的文件:
Chapter 1
12:45
First Video
39:21
Second Video
视频长度前面有制表符。我想将其转换为:
Chapter 1
First Video 12:45
Second Video 39:21
换句话说,使用“查找和替换”将一行连接到下一行的末尾等等?
答案1
打开“查找和替换”对话框
- 找什么:
(\t\d\d:\d\d)\r\n([^\n]+?)(\r\n|$)
- 用。。。来代替:
\2\1\r\n
- 勾选“正则表达式”
然后全部替换
匹配字符串找到以制表符 ( ) 开头的时间,\t\d\d:\d\d
然后在下一行获取标题。最后以相反的顺序打印标题和时间
答案2
- Ctrl+H
- 找什么:
^(\t+\d\d:\d\d)\R(.+)$
- 用。。。来代替:
$2$1
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
^ # beginning of line
( # start group 1
\t+ # 1 or more tabulations
\d\d:\d\d # 2 digits, a colon, 2 digits (the duration)
) # end group 1
\R # any kind of linebreak (i.e. \r, \n, \r\n)
(.+) # group 2, 1 or more any character but newline (the title)
$ # end of line
替代品:
$2 # content of group 2, the title
$1 # content of group 1, the duration
屏幕截图(之前):
屏幕截图(之后):