I agree that a good codebase should generally have its regex segregated into standalone functions with their own tests (ideally property-based tests!).