regex.src
re = {} re.match = function(regexp, text) if regexp[0] == "^" then regexp.pull return self.match_here(regexp,text) end if while text.len > 0 if self.match_here(regexp, text) then return 1 text.pull end while return 0 end function re.match_here = function(regexp, text) if not regexp then return 1 if regexp.len > 1 and regexp[1] == "*" then //return self.match_star(regexp[0], regexp[2:], text) char = regexp.pull regexp.pull return self.match_star(char, regexp, text) end if if regexp[0] == "$" and not regexp.hasIndex(1) then if text.hasIndex(1) then return 0 else return 1 end if if text.len > 0 and (regexp[0] == "." or regexp[0] == text[0]) then //return self.match_here(regexp[1:], text[1:]) regexp.pull text.pull return self.match_here(regexp,text) end if return 0 end function // re.match_star needs work. misses certain cases. re.match_star = function(c, regexp, text) while text.len and (text[0] == c or c == ".") if self.match_here( regexp, text) then return 1 //text = text[1:] text.pull end while return 0 end function // // c match any literal char c // ^ match from beginning of line // $ match from end of line ($ goes at end of pattern) // . matches any unicode char // * matches zero or more of preceding char