Find a regular expression !!!!!!!

Source: Internet
Author: User
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 600004
  • STR; 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!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.