Refactored handling of regex anchoring