MCPcopy Create free account
hub / github.com/LeeeSe/MessAuto / extract_verification_code

Function extract_verification_code

src/parser.rs:4–26  ·  view source on GitHub ↗
(content: &str)

Source from the content-addressed store, hash-verified

2use fancy_regex::Regex;
3
4pub fn extract_verification_code(content: &str) -> Option<String> {
5 let config = Config::load().unwrap_or_default();
6
7 let keyword_bounds = find_first_keyword_position(content, &config.verification_keywords);
8 if keyword_bounds.is_none() {
9 return None;
10 }
11 let keyword_bounds = keyword_bounds.unwrap();
12
13 let candidates = extract_candidate_codes(content, &config.verification_regex);
14 if candidates.is_empty() {
15 return None;
16 }
17
18 let filtered_candidates = filter_candidates_step1(candidates, content);
19 if filtered_candidates.is_empty() {
20 return None;
21 }
22
23 let result = find_closest_candidate(filtered_candidates, keyword_bounds);
24
25 result
26}
27
28fn find_first_keyword_position(text: &str, keywords: &[String]) -> Option<(usize, usize)> {
29 let text_lower = text.to_lowercase();

Callers 3

process_fileMethod · 0.85
process_fileMethod · 0.85

Calls 4

extract_candidate_codesFunction · 0.85
filter_candidates_step1Function · 0.85
find_closest_candidateFunction · 0.85