I have the below template 1000 times and need to extract the value between library and \n\n\n\n
:
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
How can I do that using regular expressions and perl?
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;
if ( $str =~ (?:library\s?)(.*?)(?:\\n|$) ) {
$field = $1;
}
Should capture the x.y.z value, as long as the string is always preceded by the word "library". The regex $1 value is only filled if a match is found.
精彩评论