# Check each pattern for ptype, regex in patterns.items(): if re.match(regex, plate): # Extract province if applicable province = None if ptype == "private_province": code = plate.split('.')[0] province = province_map.get(code, "Unknown province") elif ptype == "private_phnom_penh": province = "Phnom Penh" return "valid": True, "type": ptype, "province": province, "normalized": plate, "raw": plate
| Type | Format Example | Description | |------|---------------|-------------| | Private (Phnom Penh) | 2A-1234 | Number + letter + digits | | Private (Province) | PP.1234 | Province code (Khmer or Latin) | | Tourist/Temporary | 1234 T | Digits + T | | Commercial (Taxi) | 1234 TT | Digits + TT | | Diplomatic | CD 123 | CD + number | | Military | យុក 1234 or KHM 1234 | Special prefixes | | Government | PK 1234 | PK + number | : Formats may change. Always check with Cambodia’s Ministry of Public Works and Transport for latest updates. 2. Core Logic for a “Check Plate” Function (Python Example) This function validates the format and extracts province/type.
# If no pattern matches return "valid": False, "type": "unknown", "province": None, "normalized": plate, "raw": plate, "error": "Format not recognized" check plate number cambodia
# Patterns for different plate types patterns = "private_phnom_penh": r"^\d1,2[A-Z]-\d3,4$", # e.g., 2A-1234 "private_province": r"^[A-Z]2,3\.\d3,4$", # e.g., PP.1234 "tourist": r"^\d3,4\s?T$", # e.g., 1234T "commercial_taxi": r"^\d3,4\s?TT$", # e.g., 1234TT "diplomatic": r"^CD\s?\d2,3$", # e.g., CD123 "government": r"^PK\s?\d3,4$", # e.g., PK1234 "military_latin": r"^KHM\s?\d3,4$", # e.g., KHM1234 "military_khmer": r"^[\u1780-\u17FF]+\s?\d3,4$", # Khmer script detection
# Mapping province codes (Latin) province_map = "PP": "Phnom Penh", "BM": "Banteay Meanchey", "BT": "Battambang", "KG": "Kampong Cham", "KH": "Kampong Chhnang", "KS": "Kampong Speu", "KT": "Kampong Thom", "KP": "Kampot", "KD": "Kandal", "KH": "Kep", "KK": "Koh Kong", "PA": "Pailin", "PG": "Preah Sihanouk", "PS": "Preah Vihear", "PO": "Prey Veng", "PU": "Pursat", "RT": "Ratanakiri", "SR": "Siem Reap", "ST": "Stung Treng", "SV": "Svay Rieng", "TA": "Takeo", "TB": "Tbong Khmum", "OC": "Oddar Meanchey" # Check each pattern for ptype, regex in patterns
I understand you're asking about developing a piece (likely a software function or script) to .
To help you effectively, I’ll outline the key requirements and provide a structured approach. Cambodia’s license plate system has several formats depending on the vehicle type (private, commercial, tourist, diplomatic, military, etc.). Common formats as of current regulations: Core Logic for a “Check Plate” Function (Python
import re def check_cambodia_plate(plate: str): """ Validate and parse a Cambodian vehicle license plate. Returns dict with status, type, province (if applicable), and raw input. """ plate = plate.strip().upper()