我想在我的字符串中前两次出现"
之间提取字符。
示例:
my $string = 's.w;;wq[]][.zaw"this is what I need"as.w;;wq[]][.zaw"this I do not need".w;;wq[]][.za';
提前感谢您解决我的问题:)
答案 0 :(得分:0)
看看perlretut - Using Character Classes。
正如所示:
use strict;
use warnings;
my $string = q{s.w;;wq[]][.zaw"this is what I need"as.w;;wq[]][.zaw"this I do not need".w;;wq[]][.za};
if ( $string =~ /"([^"]*)/ ) {
print "$1\n";
}
输出:
this is what I need
或者只使用split
my $desire = ( split /"/, $string )[1];
答案 1 :(得分:0)
正则表达式是:/"([^"]*)"/
:
my ($wanted_string) = $string =~ /"([^"]*)"/;