"""Citation validation utilities.""" from __future__ import annotations import re PLACEHOLDER_PATTERNS = [ r"\bxx+\b", r"\bxxxx\b", r"art\.\s*no\.\s*xx", r"\bforthcoming\b", r"\bTBD\b", r"pages?\s+xx", r"vol\.\s+xx", ] _PLACEHOLDER_RE = re.compile("|".join(PLACEHOLDER_PATTERNS), re.IGNORECASE) def detect_placeholders(text: str) -> list[str]: """Return list of placeholder strings found in text.""" return _PLACEHOLDER_RE.findall(text) def is_valid_doi(doi: str) -> bool: """Basic DOI format check.""" return bool(re.match(r"^10\.\d{4,}/\S+$", doi.strip())) def is_valid_arxiv_id(arxiv_id: str) -> bool: """Check arXiv ID format (YYMM.NNNNN).""" return bool(re.match(r"^\d{4}\.\d{4,5}(v\d+)?$", arxiv_id.strip()))