Find a regular expression !!!!!!! Regular expression
Http://bbs.10jqka.com.cn/codelist.html
Obtain some content in the above link
There are three types of funds: Shenzhen, Shanghai, and Shanghai.
What I need to obtain is the stock name and stock code.
For example:
Pudong Development Bank 600000
Baiyun airport 600004
Obtain results
Pudong Development Bank 600000
Baiyun airport 600004
Can be directly obtained
$ A = array ("600000" => "Pudong Development Bank ")
This array is better.
Thank you!
Reply to discussion (solution)
preg_match_all('/]+>(.+)<\/a><\/li>/isU',$s,$m);print_r($m[1]);
$ Str = <
Pudong Development Bank 600000
Baiyun airport 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 );
]+>([^\d]+)(\d{6})<\/a><\/li>/isU',$str,$match);$a = array_combine(array_values($match[2]),array_values($match[1]));print_r($a);
]+>([^\d]+)(\d{6})<\/a><\/li>/isU',$str,$match);$a = array_combine(array_values($match[2]),array_values($match[1]));print_r($a);
Thank you. you can use this.
How can I convert the generated array from gbk to utf8?
Failed to switch after several attempts
$ 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 ($ );
$ 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 ($ );
Thank you.
$ 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 ($ );
How can I save the subscript prefix 0, 3, and 6 in the $ a array, and delete the remaining ones?
Is there any simple method?
That is, as long as the data of Shenzhen city and Shanghai city is not needed by the fund
Preg_match_all ('/
] +> ([^ \ D] +) (\ d {6}) <\/a> <\/li>/isU ', $ str, $ match );
Change
Preg_match_all ('/
] +> ([^ \ D] +) ([036] \ d {5}) <\/a> <\/li>/isU ', $ str, $ match );
Preg_match_all ('/
] +> ([^ \ D] +) (\ d {6}) <\/a> <\/li>/isU ', $ str, $ match );
Change
Preg_match_all ('/
] +> ([^ \ D] +) ([036] \ d {5}) <\/a> <\/li>/isU ', $ str, $ match );
Thank you!