匹配字符串中的表达式 - davy-gan/web GitHub Wiki
function resolverStr(str) {
console.log(str);
const opList = ['>=', '<=', '!=', '==', '>', '<'];
const compValue = {};
for (const index in opList) {
const op = opList[index];
const opPos = str.lastIndexOf(op);
if (opPos == -1) {
continue;
}
console.log(op, 'op');
compValue.expression = str.substring(2, opPos - 1);
compValue.comparison = str.substring(opPos, opPos + op.length);
compValue.num = str.substring(opPos + op.length, str.length - 1);
console.log(compValue, 'compValue');
return compValue;
//break;
}
}