/**html
*ui
*/
function isCarLicense($license)
{編碼
if (empty($license)) { return false; } #匹配民用車牌和使館車牌 # 判斷標準 # 1,第一位爲漢字省份縮寫 # 2,第二位爲大寫字母城市編碼 # 3,後面是5位僅含字母和數字的組合 { $regular = "/[京津冀晉蒙遼吉黑滬蘇浙皖閩贛魯豫鄂湘粵桂瓊川貴雲渝藏陝甘青寧新使]{1}[A-Z]{1}[0-9a-zA-Z]{5}$/u"; preg_match($regular, $license, $match); if (isset($match[0])) { return true; } } #匹配特種車牌(掛,警,學,領,港,澳) #參考 https://wenku.baidu.com/view/4573909a964bcf84b9d57bc5.html { $regular = '/[京津冀晉蒙遼吉黑滬蘇浙皖閩贛魯豫鄂湘粵桂瓊川貴雲渝藏陝甘青寧新]{1}[A-Z]{1}[0-9a-zA-Z]{4}[掛警學領港澳]{1}$/u'; preg_match($regular, $license, $match); if (isset($match[0])) { return true; } } #匹配武警車牌 #參考 https://wenku.baidu.com/view/7fe0b333aaea998fcc220e48.html { $regular = '/^WJ[京津冀晉蒙遼吉黑滬蘇浙皖閩贛魯豫鄂湘粵桂瓊川貴雲渝藏陝甘青寧新]?[0-9a-zA-Z]{5}$/ui'; preg_match($regular, $license, $match); if (isset($match[0])) { return true; } } #匹配軍牌 #參考 http://auto.sina.com.cn/service/2013-05-03/18111149551.shtml { $regular = "/[A-Z]{2}[0-9]{5}$/"; preg_match($regular, $license, $match); if (isset($match[0])) { return true; } } #匹配新能源車輛6位車牌 #參考 https://baike.baidu.com/item/%E6%96%B0%E8%83%BD%E6%BA%90%E6%B1%BD%E8%BD%A6%E4%B8%93%E7%94%A8%E5%8F%B7%E7%89%8C { #小型新能源車 $regular = "/[京津冀晉蒙遼吉黑滬蘇浙皖閩贛魯豫鄂湘粵桂瓊川貴雲渝藏陝甘青寧新]{1}[A-Z]{1}[DF]{1}[0-9a-zA-Z]{5}$/u"; preg_match($regular, $license, $match); if (isset($match[0])) { return true; } #大型新能源車 $regular = "/[京津冀晉蒙遼吉黑滬蘇浙皖閩贛魯豫鄂湘粵桂瓊川貴雲渝藏陝甘青寧新]{1}[A-Z]{1}[0-9a-zA-Z]{5}[DF]{1}$/u"; preg_match($regular, $license, $match); if (isset($match[0])) { return true; } } return false;
}code