Convert string into regex for comparison