通过正则取html页面的meta信息的问题
lp 2006-06-15 03:18:05 用一个正则取html页面中meta的一些信息,包括title,以及charset
title通过以下
preg_match_all('/<title>(.*)<\/title>/si', $html, $matches);
$title = $matches[1][0];
charset通过
preg_match_all('/<meta.*charset=([^;]*)">/i', $html, $matches);
取title的一切正常,但charset有时就不正常
比如在碰到<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
或者<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
都取不正确
求一个通用的取charset的正则