Refactored reg exp module