2013-02-11 59 views
0

我怎样写一个正则表达式从以下提取“所需的文本”:preg_match我该如何解压?

data-zoom-image="desired text" 
+1

也许你想在这里看看:HTTP: //www.php.net/manual/en/book.dom.php – biziclop 2013-02-11 08:08:54

+0

也许http://php.net /manual/en/function.preg-match.php这可以帮助你 – ripa 2013-02-11 08:10:12

回答

1
preg_match('/(data-zoom-image=")(.*)(")/',$youstring,$match); 

echo $match[2]; 

尝试。 这是一个pattren

1

你不需要preg_match做这个操作。

简单,你可以使用串联一个substrstrpos

$find = substr($yourString,strpos($yourString,"=")); 
0

无配额:

substr($text, strpos($text, '"')+1, strrpos($text, '"') - strpos($text, '"')-1) ;