(s: String)
| 1 | pub fn count_asterisks(s: String) -> i32 { |
| 2 | let mut outside = true; |
| 3 | let mut tmp_s = String::new(); |
| 4 | for c in s.chars() { |
| 5 | if outside { |
| 6 | if c != '|' { |
| 7 | tmp_s.push(c); |
| 8 | } else { |
| 9 | outside = false; |
| 10 | } |
| 11 | } else { |
| 12 | if c == '|' { |
| 13 | outside = true; |
| 14 | } |
| 15 | } |
| 16 | } |
| 17 | tmp_s.matches(|c|c=='*').count() as i32 |
| 18 | } |
| 19 | |
| 20 | fn main() { |
| 21 | println!("{:?}",count_asterisks("yo|uar|e**|b|e***au|tifu|l".to_string())); |