使用perl regex查询提取imdb id

时间:2014-04-21 15:44:19

标签: regex perl

{
"initial_release_date": "1982-12-17",
"imdb_id": [
"tt0086617"
],
"type": "/film/film",
"timestamp": "2006-10-22T09:26:51.0012Z",
"name": "The Year of Living Dangerously",
"mid": "/m/07hvh"
}
],'

我想使用perl REGEX查询从JSON查询中提取imdb id。有人知道吗?...

1 个答案:

答案 0 :(得分:0)

#!/usr/local/bin/perl
use strict;
use warnings;

my $myString = 'initial_release_date": "1982-12-17", "imdb_id": [ "tt0086617" ], "type": "/film/film", "timestamp": "2006-10-22T09:26:51.0012Z", "name": "The Year of Living Dangerously", "mid": "/m/07hvh" }';

if($myString =~ /"imdb_id":\s+\[\s+"(.*?)"\s+\]/i){
print  $1;
#tt0086617
}