早教吧作业答案频道 -->其他-->
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 ...的网友还看了以下:
求教语文老师,如果括号里引述的是一句句子,要加句号吗?比如:今年新产品的业绩表现很好(初步估计收益 2020-05-15 …
100:00:09,855 --> 00:00:14,724Britain was an obje 2020-05-17 …
“但是”前面可以用句号吗?我在校稿,具体句子:人吃谷物,即是俗.但是谁又能脱俗呢?如果前面用逗号, 2020-05-21 …
如何判断一句话什么时候说完比如:我一放学就往奶奶家赶,因为奶奶生病了.我推开门,就看见奶奶躺在床上 2020-06-28 …
如何用ReplacePioneer把文本内容按照标点符号,分割成一句一句的如何用ReplacePi 2020-07-15 …
就是问下标点作者想到与之有异曲同工之妙的“借问酒家何处有,牧童遥指杏花村.”这句话后面还用再跟标点 2020-07-22 …
如何用正则表达式匹配英文句子Nowalmosteveryotherattackisadoublet 2020-07-23 …
请教一个正则表达式其形式是第一个只能数字(0-9)+一个英文句号+两位数字(0-9),如2.00, 2020-07-23 …
有一道有挑战性的运筹模型需要求解,某医院昼夜24小时各时段内需要的护士数量如下:2:00--6:0 2020-08-04 …
仿写句子文章各有标点,如逗号,问号,感叹号,省略号,句号等,人生之路耶有各种"标点",请从任意三个标 2020-11-26 …