Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub fn htm_tag(s: &str) -> Option<&str> {
  let mut iter = s.char_indices();
  if let Some((pos, c)) = iter.next()
    && c.is_ascii_alphabetic()
  {
    let begin = pos;
    let mut end = s.len();
    for (pos, c) in iter {
      if !c.is_alphanumeric() {
        end = pos;
        break;
      }
    }
    return Some(&s[begin..end]);
  }
  None
}