Regex for Canadian postal code

Post Reply
karamike
Posts: 6
Joined: Wed Jan 02, 2019 1:15 pm

Regex for Canadian postal code

Post by karamike »

The API call https://json.schedulesdirect.org/201412 ... /countries

returns an unusual regex for the Canadian postal code. It's the only entry in the entire list with additional modifiers at the end (/gm). I wonder if this is intentional

Code: Select all

{
    "North America": [
        {
            "fullName": "United States",
            "shortName": "USA",
            "postalCodeExample": "12345",
            "postalCode": "/\\d{5}/"
        },
        {
            "fullName": "Canada",
            "shortName": "CAN",
            "postalCodeExample": "K1A0B1",
            "postalCode": "/[A-Z]{1}[\\d]{1}[A-Z]{1}[\\d]{1}[A-Z]{1}[\\d]{1}/gm"
        }
    ],
    "Europe": [
        {
        ...
        
Post Reply