/** * 提取css中带有calc函数的表达式的参数部分 * @param {String} str css中带有calc函数的表达式 */ function unCalc(str) { if (str.startsWith('calc(')) { let _str = str.replace('calc(', '') _str = _str.replace(/\)/g, (match, offset, string) => { if (offset === string.lastIndexOf(match)) { return '' } else { return match } }) return _str } else { return str } } export { unCalc }