bookwyrm/bookwyrm/utils/regex.py

11 lines
416 B
Python
Raw Normal View History

2021-03-08 16:49:10 +00:00
""" defining regexes for regularly used concepts """
2020-11-01 18:57:17 +00:00
2021-06-18 21:12:56 +00:00
DOMAIN = r"[\w_\-\.]+\.[a-z]{2,}"
LOCALNAME = r"@?[a-zA-Z_\-\.0-9]+"
STRICT_LOCALNAME = r"@[a-zA-Z_\-\.0-9]+"
2021-09-18 18:32:00 +00:00
USERNAME = rf"{LOCALNAME}(@{DOMAIN})?"
STRICT_USERNAME = rf"\B{STRICT_LOCALNAME}(@{DOMAIN})?\b"
FULL_USERNAME = rf"{LOCALNAME}@{DOMAIN}\b"
# should match (BookWyrm/1.0.0; or (BookWyrm/99.1.2;
2021-06-18 21:12:56 +00:00
BOOKWYRM_USER_AGENT = r"\(BookWyrm/[0-9]+\.[0-9]+\.[0-9]+;"