我需要在数组之间插入符号,如下所示。
my $string = "hi how r u<what is your name>what is your age";
我需要grep as
$str = what is yourname;
答案 0 :(得分:1)
或者,在Perl中:
$string =~ /\?(.+)\?/;
$result = $1;
答案 1 :(得分:1)
您可以使用下面的捕获组。
use strict;
use warnings;
my $line = "hi how r u?what is your name?what is your age";
my @str = $line =~ m/\?([^?]*)\?/g;
print "@str\n";
输出:
what is your name
答案 2 :(得分:1)
您可以在此元字符上拆分字符串。
my @results = split /\?/, $string;
print $results[1];