From 0dbcf8d8d0e13869aeb19c53e5d18a50a2088549 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Fri, 25 Mar 2022 11:50:08 -0400 Subject: [PATCH] Make like matching more forgiving by ignoring whitespace --- .../src/lang/vocabulary/filters/field_like_filter.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mps-interpreter/src/lang/vocabulary/filters/field_like_filter.rs b/mps-interpreter/src/lang/vocabulary/filters/field_like_filter.rs index d40d4f6..bd79c34 100644 --- a/mps-interpreter/src/lang/vocabulary/filters/field_like_filter.rs +++ b/mps-interpreter/src/lang/vocabulary/filters/field_like_filter.rs @@ -44,8 +44,9 @@ impl MpsFilterPredicate for FieldLikeFilter { _ => Err(RuntimeMsg("Value is not type String".to_string())), }?; if let Some(field) = music_item_lut.field(&self.field_name) { - let field_str = field.as_str().to_lowercase(); - Ok(field_str.contains(&variable.to_lowercase())) + let pattern = |c: char| c.is_whitespace() || c.is_control() || !c.is_alphanumeric(); + let field_str = field.as_str().replace(pattern, "").to_lowercase(); + Ok(field_str.contains(&variable.replace(pattern, "").to_lowercase())) } else { match self.field_errors { FieldFilterErrorHandling::Error => Err(RuntimeMsg(format!(