Skip to content
Snippets Groups Projects
Commit f25fdb9c authored by cyan's avatar cyan
Browse files

Added IRC_match(), which allows users to match against so-called

"IRC wildcards": * = Any 0 or more characters, ? = Any 1 character only.
i.e. IRC_match("cyan@gammos.weyland-yutani.net","*@*.WEYLAND-YUTANI.NET")
returns a match, whereas IRC_match("usr@something.com","????@*.com") does not.
parent ce7c549b
No related branches found
No related tags found
No related merge requests found
......@@ -129,3 +129,18 @@ function IRC_quit(server,reason) {
server.send("QUIT :" + reason + "\r\n");
}
// This function is intended to match against so-called "IRC wildcards", which
// is a simple wildcarding syntax (* = match 0 or more characters, ? = always
// match one character only.) The match is case insensitive.
// EXAMPLE: IRC_match("cyan@weyland-yutani.net","*@weyland-yutani.net");
// RETURNS: Same as Javascript match() (the matched string on success, or
// false on failure)
function IRC_match(mtchstr,mask) {
var final_mask="^";
mask=mask.replace(/[.]/g,"\\\.");
mask=mask.replace(/[?]/g,".");
mask=mask.replace(/[*]/g,".*?");
final_mask=final_mask + mask + "$";
return mtchstr.toUpperCase().match(final_mask.toUpperCase());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment