/lib/utils.py

https://github.com/3n1b-com/3n1b.com · Python · 11 lines · 4 code · 3 blank · 4 comment · 1 complexity · 73a50b8f5328bc51288d9ebb6900680e MD5 · raw file

  1. #!/usr/bin/env python
  2. # coding=utf-8
  3. #
  4. # Copyright 2013 3n1b.com
  5. import re
  6. def find_mentions(content):
  7. regex = re.compile(ur"@(?P<username>(?!_)(?!.*?_$)(?!\d+)([a-zA-Z0-9_\u4e00-\u9fa5]+))(\s|$)", re.I)
  8. return [m.group("username") for m in regex.finditer(content)]