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.如果以句号为分割,把对应的时

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 16:24:08

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菜鸟,望指教

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.如果以句号为分割,把对应的时
正则表达式(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 程序中的一点难点,不过如果能够很好的掌握他,就可以轻易地用正则表达式来完成字符串处理的任务,当然在设计中就更能得心应手了.

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.如果以句号为分割,把对应的时 关于perl的问题 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.如果以句号为分 关于perl的问题 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.如果以句号为分 英语翻译0001B214 4D 53 46 54 02 00 01 00 00 00 00 00 09 04 00 00 MSFT晻晻晻晻晻晻0001B224 00 00 00 00 41 00 00 00 01 00 00 00 00 00 00 00 晻晻A晻晻晻晻晻?0001B234 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 晻晻晻晻晻晻晻 00 00 00 这个什么规约报文,[2011-04-20 08:58:20,589] COM2-> 68 A6 00 A6 00 68 88 03 12 01 00 02 0A 68 00 00 02 01 01 00 01 00 01 00 42 01 33 03 00 00 00 00 00 00 00 00 00 00 04 09 00 00 00 00 00 00 11 AF 16[2011-04-20 08:58:20,433] COM2 22:30减09:00等于多少? 7+1+00-100=? 美国CST时间09:00,我们这里几点? 2009-08-30 17:12:00 到 2009-09-02 09:27:00 有几小时几分几秒 00 00是几点 00:00什么意思 00:00是几点? 00:00是什么意思 modbus 下面帧各代表什么意思啊read ts>01 03 64 05 00 00 A5 00 00 00 04 00 00 00 00 00 C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 关于perl的问题现有a文件100:00:16,000 --> 00:00:19,000When I was 10 years old,200:00:19,000 --> 00:00:22,000a cousin of mine took me on a tour of his medical school.300:00:22,000 --> 00:00:24,000And as a special treat400:00:24,000 --> 00:00:2