匹配多行文本 /m用法
来源:互联网 发布:vb.net 教程 编辑:程序博客网 时间:2024/04/30 01:55
1
00:00:09,855 --> 00:00:14,724
Britain was an object of desire.
2
00:00:26,295 --> 00:00:31,847
Tacitus declared it worth the conquest,
3
00:00:32,015 --> 00:00:35,803
the best compliment
that could occur to a Roman.
如果以句号为分割,把对应的时间合并起来,最后得到下面的结果:
1
00:00:09,855 --> 00:00:14,724
Britain was an object of desire.
2
00:00:26,295 --> 00:00:35,803
Tacitus declared it worth the conquest,
the best compliment
that could occur to a Roman.
————————————————————————————————————————————————
#!/usr/bin/perl
#ans.pl
my $file;
while (<>){s/^/s+$//;$file.=$_};
my @data=split//./,$file;
for (@data){
/.*(^/d.*>.*/d$)/sm; #由于@data中是按分段文本存放,所以需要用到多行匹配,/s表示匹配/n,/m多行匹配
my $time=$1;
s/^/d+:.*/d$//gm; #删除时间行
s/^/d+/n//gm; #删除数目行
s/$/./; #加上点号
s//n+//n/g; #删除空行
print ++$num,"/n",$time,$_,"/n";
}
=====================
perl ans.pl yourfile.txt
- 匹配多行文本 /m用法
- 正则表达式匹配多行文本
- 用正则匹配多行文本
- 正则表达式匹配多行文本的解决方法
- 打印多行文本
- 多行文本绘制
- 多行文本框
- 多行文本绘制
- 多行文本溢出
- 多行文本溢出
- 控制多行文本
- 多行文本居中
- Swift - 多行文本输入框(UITextView)的用法
- SetDlgItemText显示多行文本
- 多行文本弹出窗口
- ORACLE 多行文本合并
- libgdx 多行文本域
- vim 注释多行文本
- 转载——bootloader 开发,最郁闷前三步
- Ubuntu Server 上传文件的方法
- 一点arm程序优化的经验
- 强烈抗议在广告时间插播电视剧,呵呵,还真有这么回事
- Linux C 格式化输出时要注意的问题
- 匹配多行文本 /m用法
- JPA注解 转载
- JSP九大内置对象及四个作用域
- 层次遍历二叉树
- response.setHeader()的用法
- 重新移植了一下内核--记之备忘
- hibernate 中文查询
- BSP、BIOS、Bootloader介绍
- GNOME3 截图画廊