Validate Gender using Regular Expressions
Improve Article
Save Article
Like Article
Improve Article
Save Article
Given some words of Gender, the task is to check if they are valid or not using regular expressions. The correct responses can be as given below:Male / male / MALE / M / mFemale / female / FEMALE / F / fNot prefer to sayExample:Input: MOutput: TrueInput: SOutput: FalseApproach: The problem can be solved based on the following idea:Create a regex pattern to validate the number as written below: regex=…