var regStr = "@prefix\\s+([^;]+);"; var globalRegex = new RegExp(regStr, "g"); var localRegex = new RegExp(regStr); var prefixes = ["-moz-", "-webkit-", "-o-", "-ms-", ""]; module.exports = function(str) { var matches = str.match(globalRegex); if (!matches) return str; matches.forEach(function(m) { var cssProperty = m.match(localRegex)[1]; var res = ""; prefixes.forEach(function(prefix) { res += prefix+cssProperty+"; "; }); res = res.substring(0, res.length - 1); str = str.replace(m, res); }); return str; }