From 49192dbb98e0ab1f2a66b4786fac86d63f69be64 Mon Sep 17 00:00:00 2001 From: "1992414357@qq.com" <1992414357@qq.com> Date: Mon, 9 Jun 2025 01:44:36 +0800 Subject: 重构所有部分 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/string_utils.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/string_utils.rs (limited to 'src/string_utils.rs') 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 -- cgit