Guest User

Untitled

a guest
Jun 13th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. embeddedString = embeddedString.replace(/(widths*=s*["'])[0-9]+(["'])/ig, $1 + yourWidth + $2);
  2. embeddedString = embeddedString.replace(/(heights*=s*["'])[0-9]+(["'])/ig, $1 + yourHeight + $2);
  3.  
  4. embeddedString = embeddedString.replace(/widths*=s*["']["']/ig, function($0, $1)
  5. {
  6. return $1 * 2;
  7. });
  8.  
  9. var originalWidth;
  10. var originalHeight;
  11. embeddedString = embeddedString.replace(/(?:width|height)s*=s*["']([0-9]+)["']s*(?:width|height)s*=s*["']([0-9]+)["']/ig, function($0, $1, $2, $3, $4)
  12. {
  13. // $0 = original string
  14. // $1 = either 'width' or 'height'
  15. // $2 = the value of width or height, depending on above
  16. // $3 = either 'width' or 'height'
  17. // $4 = the value of width or height, depending on above
  18. // here you might want to set another value, eg:
  19. originalWidth = $2;
  20. return "";
  21. });
  22.  
  23. width="(.*?)" height="(.*?)"
  24.  
  25. $pattern = '/width="(.*?)" height="(.*?)"/';
  26. $subject = 'width="500" height="300"';
  27.  
  28. preg_match($pattern, $subject, $matches);
  29.  
  30. print_r($matches);
Add Comment
Please, Sign In to add comment