openzeppelin_monitor/utils/
expression.rspub fn split_expression(expr: &str) -> Option<(&str, &str, &str)> {
let mut in_quotes = false;
let mut operator_start = None;
let mut operator_end = None;
let operators = [
"==",
"!=",
">=",
"<=",
">",
"<",
"contains",
"starts_with",
"ends_with",
];
for (i, c) in expr.char_indices() {
if c == '\'' || c == '"' {
in_quotes = !in_quotes;
continue;
}
if !in_quotes {
for op in operators {
if expr[i..].starts_with(op) {
operator_start = Some(i);
operator_end = Some(i + op.len());
break;
}
}
if operator_start.is_some() {
break;
}
}
}
if let (Some(op_start), Some(op_end)) = (operator_start, operator_end) {
let left = expr[..op_start].trim();
let operator = expr[op_start..op_end].trim();
let right = expr[op_end..].trim();
let right = right.trim_matches(|c| c == '\'' || c == '"');
Some((left, operator, right))
} else {
None
}
}