zoukankan      html  css  js  c++  java
  • 常用正则表达式整理(持续更新中)

    常用正则表达式整理(持续更新中)

    1、替换商品详情中图片的高和宽

    1 $str = '<p><img src="/uploads/20190308/FuwOxhHmoE8JP1rA_kg2JDTMFsGf.jpg" alt="" width="500" height="481" />
    2 <img src="/uploads/20190308/FjGfFmn4_9XskCQ4rwSJ6EayDHfA.jpg" alt="" width="500" height="481" />
    3 <img src="/uploads/20190308/Fvf3IzrGs-_0ak8hztGjlWc4IR1T.png" alt="" width="500" height="441" /></p>';
    4 echo $str;
    5 $str = preg_replace('/width="(d+)"/', 'width="100%"', $str);
    6 $str = preg_replace('/height="(d+)"/', 'height="100%"', $str);
    7 echo $str;die;

    2、验证手机号字段

    1     protected function checkMobile($str)
    2     {
    3         return (preg_match("/^1[0-9]{1}[0-9]{9}$/",$str)) ? true : false;
    4     }

    3、验证金额,价格字段

    1     protected function checkPrice($str)
    2     {
    3         return (preg_match("/^d{1,8}(.d{1,2})?$/",$str)) ? true : false;
    4     }
  • 相关阅读:
    Spring----Day03
    Spring----Day02
    python
    python
    python
    python
    python
    python
    python
    python
  • 原文地址:https://www.cnblogs.com/cyfblogs/p/10509235.html
Copyright © 2011-2022 走看看