我正在制作一个 java IRC lib,我需要一种方法来查看某个用户是否匹配可以包含通配符的主机掩码*
。不使用正则表达式的最简单方法是什么?
一些例子:
// 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 ✘