早教吧作业答案频道 -->其他-->
100:00:09,855 --> 00:00:14,724Britain was an object of desire.200:00:26,295 --> 00:00:31,847Tacitus declared it worth the conquest,300:00:32,015 --> 00:00:35,803the best complimentthat 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: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.
perl菜鸟,望指教
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.
perl菜鸟,望指教
▼优质解答
答案和解析
正则表达式(Regular Expression)方法可以满足你上面所需的要求.
Perl的正则表达式功能十分强大,基本上是常用语言中最强大的.本解使用Perl正则表达式中最基本、最常用的部分.
#!/usr/bin/perl
#ans.pl
my $file;
while (){s/^\s+$//;$file.=$_};
my @data=split/\./,$file;
for (@data){
/.*(^\d.*>.*\d$)/sm;
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
正则表达式是 Perl 语言的一大特色,也是 Perl 程序中的一点难点,不过如果能够很好的掌握他,就可以轻易地用正则表达式来完成字符串处理的任务,当然在设计中就更能得心应手了.
Perl的正则表达式功能十分强大,基本上是常用语言中最强大的.本解使用Perl正则表达式中最基本、最常用的部分.
#!/usr/bin/perl
#ans.pl
my $file;
while (){s/^\s+$//;$file.=$_};
my @data=split/\./,$file;
for (@data){
/.*(^\d.*>.*\d$)/sm;
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
正则表达式是 Perl 语言的一大特色,也是 Perl 程序中的一点难点,不过如果能够很好的掌握他,就可以轻易地用正则表达式来完成字符串处理的任务,当然在设计中就更能得心应手了.
看了 100:00:09,855 ...的网友还看了以下:
100:00:09,855 --> 00:00:14,724Britain was an obje 2020-05-17 …
在STP协议中,设所有交换机所配置的优先级相同,交换机1的MAC地址为00-e0-fc-00-00- 2020-05-31 …
①00:00和24:00有什么区别?②7月30日24:00之后一小时是7月31日1:00还是7月3 2020-07-17 …
甲、乙两人相约于下午1:00—2:00之间到某车站乘公共汽车外出他们到达车站的时间是随机的.设在下 2020-07-18 …
英语翻译[00:10.72]Goodtimesforachange[00:15.16]See,the 2020-10-30 …
英语翻译[00:10.72]Goodtimesforachange[00:15.16]See,the 2020-10-30 …
英语翻译[00:25.06]Heretonight,[00:27.60]frozenintime[0 2020-10-30 …
英语翻译[00:12.93]Thisismyface[00:18.93]Coveredinfreck 2020-10-30 …
英语翻译谁帮我翻点东西[ti:Crawling][ar:LinkinPark][al:HybridT 2020-10-30 …
excel如何把一列的时间值,按时段筛选?如A列2012/9/38:532012/9/39:2220 2021-01-01 …