javascript for chrome extension reg not defined

This is the first time creating a extension, I am creating a phishing detection chrome extension using manifest V3 and in my JavaScript I am getting the following error Uncaught ReferenceError: reg is not defined

This is the code for my js
var tdata;
var forecast;

        function URLIP(){
        var match =/d{1,3}[.]{1}d{1,3}[.]{1}d{1,3}[.]{1}d{1,3}/;
        var site = window.location.href
        if(reg.exec(site)==null){
            console.log("Not Phishing");
            return -1;
        }
        else{
            console.log("Phishing");
            return 1;
        }
        }

        function RequestURL(){
        var find = /(http|https)://[a-z0-9]+.[a-z]{2,4}/.+/;
        var site = window.location.href; 
        if(site.match(find)==null){
            console.log("Not Phishing");
            return -1;
        }
        else{
            console.log("Phishing");
            return 1;
        }
        }

        function URLAnchor() {
        var find = /(http|https)://[a-z0-9]+.[a-z]{2,4}/.+/;
        var anchors = document.getElementsByTagName('a');
        for (var i = 0; i < anchors.length; i++) {
            var href = anchors[i].getAttribute('href');
            if (href !== null && href.match(find) !== null) {
            console.log("Found phishing URL: " + href);
            return 1;
            }
        }
        console.log("No phishing URLs found");
        return -1;
        }


        function findLinks() {
        var find = /https?://[a-z0-9]+.[a-z]{2,4}/S+/gi;
        var elements = document.getElementsByTagName('*');
        for (var i = 0; i < elements.length; i++) {
            var href = elements[i].getAttribute('href');
            var src = elements[i].getAttribute('src');
            var style = elements[i].getAttribute('style');
            var match = null;
            if (href !== null) {
            match = href.match(find);
            } else if (src !== null) {
            match = src.match(find);
            } else if (style !== null) {
            match = style.match(find);
            }
            if (match !== null) {
            console.log("Found link: " + match[0]);
            return true;
            }
        }
        console.log("No links found");
        return false;
        }

        tdata = [URLIP(),RequestURL(),URLAnchor(),findLinks()]

        forecast = guess(tdata);

        chrome.extension.sendRequest(forecast);

        The reg is supposed to allow the variable to work

`
The reg is supposed to allow the variable to work