d2Length function
Implementation
String d2Length(String expression) {
RegExp hasValueRegex = RegExp(r'd2:length\(([^)]+)\)');
String replaceHasValue(Match match) {
String content = match.group(1)?.trim() ?? '';
if (content.trim().contains("''")) {
return '0';
} else {
return '${content.length}';
}
}
String value = '';
expression.replaceAllMapped(hasValueRegex, (match) {
value = replaceHasValue(match);
return value;
});
return value;
}