I am making a java IRC lib and I need a method to see if a certain user matches a hostmask which can contain a wildcard *
character. What is the simplest way to do this without using regex?
Some examples:
// Anything works
*
server.freenode.net ✔
// Any nickname/user/host works
*!*@*:
any!thing@works ✔
// Any nickname works (may have multiple nicknames on the same user)
*!nebkat@unaffiliated/nebkat:
nebkat!nebkat@unaffiliated/nebkat ✔
123456!nebkat@unaffiliated/nebkat ✔
nebkat!nebkat@unaffiliated/hacker ✘
// Anything from an ip
*!*@123.45.67.8:
nebkat!nebkat@123.45.67.8 ✔
123456!user2@123.45.67.8 ✔
nebkat!nebkat@87.65.43.21 ✘
// Anything where the username ends with nebkat
*!*nebkat@*
nebkat!nebkat@unaffiliated/nebkat ✔
nebkat!prefix_nebkat@unaffiliated/nebkat ✔
nebkat!nebkat_suffix@unaffiliated/nebkat ✘