Replacing the structure and then determining the solution

Source: Internet
Author: User
Replace the structure and then judge & lt; objectclassid = & quot; clsid: d27cdb6e-ae6d-11cf-96b8-444553540000 & quot; width = & quot; 550 & quot; height = & quot; 400 & quot; codebase = & quot; http: // replace structure with fpdown before determining



Changed:



The values of width and height are changed. if width is less than 805, the values of width and height do not need to be changed.
If width> 805
Then height = height * 805/width;
Width = 805

How can I write this regular expression? I recently used many regular expressions. how can I learn regular expressions well?


------ Solution --------------------
Describe your rules

../Documents/medies/ESIL_xiaoshengqi1.gif
This is a new one.


Image: ESIL_xiaoshengqi1.gif?



Width = "550" height = "400" what about this ??? Which one does it need?



------ Solution --------------------
Refer:
PHP code
$ S = <
  
   
   
   
    Html; $ r = preg_replace ('#. +
   
    
] *>. + # S ', '', $ s); preg_match (' # width =" (\ d +) "\ s * height =" (\ d +) "# I ', $ r, $ m); if ($ m [1]> 805) {$ h = ($ m [2] * 805) /$ m [1]; $ r = preg_replace ('/(width =) "(\ d +)" (\ s * height =) "(\ d +) "/S', '$1" $2 "$3 "'. $ h. '"', $ r);} echo $ r;
    
------ Solution --------------------
PHP code
$s =<<< TXT TXT;$r= preg_replace_callback('#.+
      
       ]*>.+#s', 'back', $s);function back($r) {  if($r[3] > 805) {    $r[4] = round($r[4]*805/$r[3]);    $r[3] = 805;  }  return <<< TXTTXT;}echo $r;
      

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.