Regex helper, minor improvements