Home > Backend Development > PHP Tutorial > Regular expression to get numbers in string

Regular expression to get numbers in string

WBOY
Release: 2016-07-25 08:42:49
Original
1125 people have browsed it
  1. $patterns = "/d+/"; //First type
  2. //$patterns = "/d/"; //Second type
  3. $strs="left:0px;top :202px;width:90px;height:30px";
  4. preg_match_all($patterns,$strs,$arr);
  5. print_r($arr);
  6. /***************operation result*********************/
  7. //First type
  8. Array
  9. (
  10. [0] => Array
  11. (
  12. [0] => 0
  13. [1] => 202
  14. [2] => 90
  15. [3] => 30
  16. )
  17. )
  18. / /Second
  19. Array
  20. (
  21. [0] =>
  22. [4] => 9
  23. [5] => 0
  24. [6] => 3
  25. [7] => 0
  26. )
  27. )
  28. Copy code
Regular expression
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template