Im trying to add a variable into a reg expression. I believe its called backreference but cannot seem to figure out how to create a string+variable to search for that cookie. I tried making it a template literal and adding a string within.
I've been referencing this similar question and have attempted many solutions but am struggling to get this to work properly.
I've tried replacing it with replaceAll("searchCookie", 'searchCookie${this.type}')
Backstory: I have a function that will create the base searchCookie + this.type inside my checkCookie function I run this command to get the cookie if it exists or not. Let me know if any details are missed and i appreciate the advice/help
cookie.match(/^(.*;)?\s*searchCookie+Variable\s*=\s*[^;]+(.*)?$/)