Regex 使用正则表达式忽略新行字符

Regex 使用正则表达式忽略新行字符,regex,perl,Regex,Perl,我有以下模板1000次,需要提取库与\n\n\n\n之间的值: 如何使用正则表达式和perl实现这一点 if ( $str =~ (?:library\s?)(.*?)(?:\\n|$) ) { $field = $1; } 应该捕获x.y.z值,只要字符串前面始终有单词库。只有在找到匹配项时,才会填充regex$1值。能否正确设置格式?我真的没有得到你想要的。。。 my $template = "this identifier L99203 which is blah\n\nto t

我有以下模板1000次,需要提取库与\n\n\n\n之间的值:

如何使用正则表达式和perl实现这一点

if ( $str =~ (?:library\s?)(.*?)(?:\\n|$) ) {
    $field = $1;
}

应该捕获x.y.z值,只要字符串前面始终有单词库。只有在找到匹配项时,才会填充regex$1值。

能否正确设置格式?我真的没有得到你想要的。。。
my $template = "this identifier L99203 which is blah\n\nto the idnetifier of the library x.y.z\n\n\n\nYou should use this number for your solution to be right\n\n\n\no yes\n\n\n\nconnect ot db " x 1000;
my @values = $template =~ /of the library (.*)\n\n\n\n/g;
my $template = "this identifier L99203 which is blah\n\nto the idnetifier of the library x.y.z\n\n\n\nYou should use this number for your solution to be right\n\n\n\no yes\n\n\n\nconnect ot db " x 1000;
my @values = $template =~ /of the library (.*)\n\n\n\n/g;