2023-03-24 05:55:34 +01:00
|
|
|
function regex_node(val, accept = false) constructor {
|
|
|
|
self.val = val;
|
|
|
|
self.accept = accept;
|
|
|
|
|
|
|
|
states = {};
|
|
|
|
|
|
|
|
static setNext = function(key, node) {
|
|
|
|
states[$ key] = node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static consume = function(key) {
|
|
|
|
return struct_has(states, key)? states[$ key] : self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function regex_tree(regx) constructor {
|
2024-05-16 04:26:35 +02:00
|
|
|
regs = string_splice(regx, ";", false, false);
|
2023-03-24 05:55:34 +01:00
|
|
|
|
|
|
|
static isMatch = function(str) {
|
2024-05-16 04:26:35 +02:00
|
|
|
for (var i = 0, n = array_length(regs); i < n; i++) {
|
|
|
|
var rgx = regs[i];
|
|
|
|
if(RegexMatch(str, rgx))
|
|
|
|
return true;
|
2023-03-24 05:55:34 +01:00
|
|
|
}
|
|
|
|
|
2024-05-16 04:26:35 +02:00
|
|
|
return false;
|
2023-03-24 05:55:34 +01:00
|
|
|
}
|
|
|
|
}
|