Revert "Revert "(PUP-2922) Fix invalid regex""

This reverts commit 1184f8ec934b08062e5ac7bdb2f340a0dae89bf8.