Function to compare wildcarded hostnames
Posted on 2004-04-08
Does anybody know of a function (or feels like writing one) that can compare a host name to a wildcarded specification, for example:
*.company.com should match a.company.com but not company.com
*any.com should match company.com or a.company.com but not company1.com
*any*.com should match a.company1.com
*boston*.*any*.com should match 23boston.company1.com
The wildcarding doesn't need to be more extensive than *, that is, no [1..9] or aything like that is required.
Regular expressions might do the trick although the overhead seems high for something so simple, and I'd like this to be as light-weight as possible.