验证车牌警车能源车

/**

*   判断是否合法车牌号
*  @name isCarLicense
*  @param $license
*  @return bool
*/
function isCarLicense($license){
    if (empty($license)) {
        return false;
    }
    //普通车牌
    $regular = "/[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/u";
    preg_match($regular, $license, $match);
    if (isset($match[0])) {
        return true;
    }
    //小型新能源汽车
    $regular =  "/[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[0-9]{5}[DF]$/u";
    preg_match($regular, $license, $match);
    if (isset($match[0])) {
        return true;
    }
    //大型新能源汽车
    $regular =  "/[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[DF][A-HJ-NP-Z0-9][0-9]{4}$/u";
    preg_match($regular, $license, $match);
    if (isset($match[0])) {
        return true;
    }
    return false;
}
不断的修改不断的完善
原文地址:https://www.cnblogs.com/lhwhqy/p/9621102.html