case foo {
    [fF][oO][oO] {}
    .* {
        echo 'failed foo [fF][oO][oO]'
    }
}

case fOo {
    [fF][oO][oO] {}
    .* {
        echo 'failed fOo [fF][oO][oO]'
    }
}

case foo {
    foo+ {}
    .* {
        echo 'failed foo+'
    }
}

case foo {
    fo+ {}
    .* {
        echo 'failed fo+'
    }
}

case foo {
    fo* {}
    .* {
        echo 'failed fo*'
    }
}

case foo {
    fo {
        echo 'failed fo'
    }
    .* {}
}

case '[]' {
    .. {}
    .* {
        echo 'failed [] ..'
    }
}

case '[]' {
    \[\] {}
    .* {
        echo 'failed [] \[\]'
    }
}

fun match_ip {
    case $1 {
        ([0-9][0-9]?[0-9]?)\.([0-9]?[0-9]?[0-9])\.([0-9]?[0-9]?[0-9])\.([0-9]?[0-9]?[0-9]) {
            if [ $2 != yes ] {
                echo "$1 should not match but it did"
            }
        }
        .* {
            if [ $2 = yes ] {
                echo "$1 should match but it did not"
            }
        }
    }
}

match_ip 192.168.1.1 yes
match_ip 999.999.999.999 yes # the IP regex is not very good but we are testing the regex engine not IP parsing.
match_ip foo no
match_ip ::1 no
match_ip 192..168.1.1 no
match_ip 192.168.1.1.1 no
match_ip 0.0.0.0 yes
match_ip 01.1.1.1 yes
match_ip 1234.0.0.1 no
