Ask PHP to extract the data of the HTML list with the regular

Source: Internet
Author: User
Chengdu E-Commerce Co., Ltd. Rosie 5101220001248473770103              Chengdu Science and Technology Co., Ltd. Huang can hair 5110400017076766531815              


PHP Novice
Ask PHP to extract the two parameters in the Javascript:detail (' R2013031500000871 ', ' 671529939 ') and the values in TD with regular,
A TR for a row, preferably into an array, thank you.


Reply to discussion (solution)

$s =<<
         Chengdu E-Commerce Co., Ltd.Rosie5101220001248473770103                                                                            Chengdu Branch Technology Co., Ltd.Huang can hair5110400017076766531815                                                                        Txt;preg_match_all ('/
  
   ]+> (. +) <\/td>/su ', $s, $m);p rint_r ($m [1]); TD Value Preg_match_all ('/
   

Oh, there's one less print parameter.
Preg_match_all ('/Print_r ($ar [1]); Parameter 1
Print_r ($ar [2]); Parameter 2

Oh, there's one less print parameter.
Preg_match_all ('/Print_r ($ar [1]); Parameter 1
Print_r ($ar [2]); Parameter 2

A TR is a line, because the actual case of TR may be multiple lines, I would like to be a TR to match, take out each line TR TD value is an array.

Preg_match_all ('/
 
     
      
  ]+>\s*
  
      
       
   ]+> (. +) <\/td>\s*
   
       
        
    ]+> (. +) <\/ td>\s*
    
        
         
     ]+> (. +) <\/td>\s*
     
         
          
      ]+> (. +) <\/td>\s*
      
          
            ] +> (. +) <\/td>\s*<\/tr>/su ', $s, $m, Preg_set_order);p Rint_r ($m); 
          
     
         
    
        
   
       
  
      
 
     

Preg_match_all ('/
 
     
      
  ]+>\s*
  
      
       
   ]+> (. +) <\/td>\s*
   
       
        
    ]+> (. +) <\/ td>\s*
    
        
         
     ]+> (. +) <\/td>\s*
     
         
          
      ]+> (. +) <\/td>\s*
      
          
            ] +> (. +) <\/td>\s*<\/tr>/su ', $s, $m, Preg_set_order);p Rint_r ($m); 
          
     
         
    
        
   
       
  
      
 
     


                

The last question, I want to take Javascript:detail (' R2013031500000871 ', ' 671529939 ') in the R2013031500000871 and 671529939, how to write it?

#1 reply The second one, isn't it?

#1 reply The second one, isn't it?

I mean a match, no more matching, two regular together

And when that happens, it's perfect.


Array ([    0] = = Array        (            [0] = = Chengdu e-commerce Co., Ltd.            [1] = Rosie            [2] = 51012200012484            [3] = = 73770103            [4] = 012121400045944            [5] = 75203619        )    [1] = = Array .....

Preg_match_all ('/ ]+>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+> (\s*.+) <\/td>\s* <\/tr>/su ', $s, $m, preg_set_order);
Print_r ($m);

Such
Preg_match_all ('/ ]+>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+>\s*.+<\/td>\s*<\/tr >/su ', $s, $m, preg_set_order);

Such
Preg_match_all ('/ ]+>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+> (. +) <\/td>\s* ]+>\s*.+<\/td>\s*<\/ Tr>/su ', $s, $m, preg_set_order);

That's it, thanks for the split.

What tools do you use to test the regular, I use match Tracer and Expresso test, you help write the regular does not match, but PHP can, there is a last of the/su what mean?

  • 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.