求個Regex!!!!!!!
http://bbs.10jqka.com.cn/codelist.html
擷取以上連結裡面的部分內容
有深市、滬市、基金三種
我需要擷取的是股票名稱和股票代號
例如:
浦發銀行 600000
白雲機場 600004
擷取結果
浦發銀行 600000
白雲機場 600004
能直接擷取成
$a=array("600000"=>"浦發銀行")
這樣的數組就更好了
在此先謝謝各位大神了
Regex
分享到:
------解決方案--------------------
preg_match_all('/]+>(.+)<\/a><\/li>/isU',$s,$m);
print_r($m[1]);
------解決方案--------------------
$str=<<
浦發銀行 600000白雲機場 600004STR;
preg_match_all("/(\S+)\s+(\d+)/",preg_replace("/<\/?[^>]+?>/",'',$str),$out,PREG_SET_ORDER);
foreach($out as $a) list($s,$o[$i],$i)=$a;
print_r($o);
------解決方案--------------------
$url ="http://bbs.10jqka.com.cn/codelist.html";
$str = file_get_contents($url);
preg_match_all('/
]+>([^\d]+)(\d{6})<\/a><\/li>/isU',$str,$match);
$a = array_combine(array_values($match[2]),array_values($match[1]));
print_r($a);
------解決方案--------------------
$url ="http://bbs.10jqka.com.cn/codelist.html";
$str = file_get_contents($url);
$str = iconv('gbk', 'utf-8', $str);
preg_match_all('/
]+>([^\d]+)(\d{6})<\/a><\/li>/isU',$str,$match);
$a = array_combine(array_values($match[2]),array_values($match[1]));
print_r($a);