JSFiddle - React, Tailwind, and code Playground

JavaScript

function escape(s) {
    return s[0].replace(/[-&\/\\^$*+?.()|[\]{}]/g, '\\$&');
};

var or = escape`||`;
var and = escape`&&`;
console.log(new RegExp(`${and}|${or}`)); // "/\&\&|\|\|/"