Pass pattern to regex.