moviewyrm/bookwyrm/utils/regex.py

11 lines
434 B
Python
Raw Normal View History

2020-11-01 18:57:17 +00:00
''' defining regexes for regularly used concepts '''
2021-01-06 17:45:36 +00:00
domain = r'[\w_\-\.]+\.[a-z]{2,}'
2021-01-07 00:01:13 +00:00
localname = r'@?[a-zA-Z_\-\.0-9]+'
2021-01-01 15:27:56 +00:00
strict_localname = r'@[a-zA-Z_\-\.0-9]+'
2020-12-31 01:36:35 +00:00
username = r'%s(@%s)?' % (localname, domain)
2021-01-06 17:45:36 +00:00
strict_username = r'\B%s(@%s)?\b' % (strict_localname, domain)
2021-01-07 00:01:13 +00:00
full_username = r'%s@%s\b' % (localname, domain)
# should match (BookWyrm/1.0.0; or (BookWyrm/99.1.2;
bookwyrm_user_agent = r'\(BookWyrm/[0-9]+\.[0-9]+\.[0-9]+;'