Ignoring numbers that contain alphabetic characters
This commit is contained in:
+16
-3
@@ -25,6 +25,12 @@ pub mod parser {
|
||||
if let Ok(lines) = self.read_lines(&self.filepath) {
|
||||
for line in lines {
|
||||
if let Ok(phonenumber) = line {
|
||||
let contains_letters = phonenumber.chars().any(|c| c.is_alphabetic());
|
||||
|
||||
if contains_letters {
|
||||
continue;
|
||||
}
|
||||
|
||||
let myobj: SomeObject = SomeObject {
|
||||
value: phonenumber
|
||||
};
|
||||
@@ -111,12 +117,19 @@ pub mod parser {
|
||||
println!("Unparsed: {}", unparsed);
|
||||
|
||||
let mut parsed: String = String::new();
|
||||
let mychars = unparsed.chars();
|
||||
|
||||
for i in 0..unparsed.len() {
|
||||
let mychar: char = unparsed.chars().nth(i).unwrap();
|
||||
let mychar_wrap = mychars.clone().nth(i);
|
||||
|
||||
if mychar.is_numeric(){
|
||||
parsed.push(mychar);
|
||||
if let None = mychar_wrap {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mychar = mychar_wrap.unwrap();
|
||||
|
||||
if mychar.is_numeric() {
|
||||
parsed.push(mychar.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user