Added belt and braces check for value in applyRegex