aboutsummaryrefslogtreecommitdiff
path: root/src/string_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/string_utils.rs')
-rw-r--r--src/string_utils.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/string_utils.rs b/src/string_utils.rs
new file mode 100644
index 0000000..7a02f25
--- /dev/null
+++ b/src/string_utils.rs
@@ -0,0 +1,16 @@
+pub fn process_id_text(input: String) -> String {
+ let s = input.trim().to_lowercase();
+ let mut result = String::new();
+
+ for c in s.chars() {
+ match c {
+ '\n' | '_' => continue,
+ '-' | '.' | ',' | ' ' => result.push('_'),
+ _ => result.push(c),
+ }
+ }
+
+ result.chars()
+ .filter(|&c| c.is_ascii_alphanumeric() || c == '_')
+ .collect()
+} \ No newline at end of file