早教吧作业答案频道 -->其他-->
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 ...的网友还看了以下:
a1=-11/7π,a2=511/6π,a3=9,a4=-855°,请把这些转化为另一种度量制 2020-04-07 …
把下面个数按从小到大的顺序排列起来1.83.3%6/50.855/42.0.589/565%5/3 2020-04-25 …
所有因数的和是31,这个数是多少?本题其实是求小于或等于31的所有质数(素数)还得把1和这个数本身 2020-04-27 …
一.420度,-75度,855度,-510度,分别是第几象限角 二.-54度18分,395一.42 2020-05-16 …
100:00:09,855 --> 00:00:14,724Britain was an obje 2020-05-17 …
把31分之4+31分之6+31分之8+31分之10+31分之12+31分之14+31分之16改写成 2020-05-17 …
求高手52张扑克牌魔术解密一副扑克牌去掉大小王,然后先摸出30张,JQK看做1,把第31张牌正面放 2020-06-15 …
去掉5.173的小数点,它的值扩大倍,把0.31的小数点向左移动二位,它的值缩小倍. 2020-07-18 …
把0.31,0.309,100分之31,3分之1按从大到小的顺序排列 2020-07-19 …
用适当的溶液把3.31克某矿石样品溶解,然后加过量碱溶液,生成沉淀,在灼烧沉淀,得到2.40克Fe2 2020-12-03 …