We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Regex
  3. Grouping and Capturing
  4. Alternative Matching

Alternative Matching

Problem
Submissions
Leaderboard
Discussions
Editorial

Alternations, denoted by the | character, match a single item out of several possible items separated by the vertical bar. When used inside a character class, it will match characters; when used inside a group, it will match entire expressions (i.e., everything to the left or everything to the right of the vertical bar). We must use parentheses to limit the use of alternations.

ach17.png

For example:

  • (Bob|Kevin|Stuart) will match either Bob or Kevin or Stuart.
  • ([a-f]|[A-F]) will match any of the following characters: a, b, c, d, e, f, A, B, C, D, E, or F.

Task

Given a test string, , write a RegEx that matches under the following conditions:

  • must start with Mr., Mrs., Ms., Dr. or Er..
  • The rest of the string must contain only one or more English alphabetic letters (upper and lowercase).

Note: This is a RegEx-only challenge. You are not required to write code; you simply need to fill in the blank.

Author

[deleted]

Difficulty

Easy

Max Score

20

Submitted By

33449

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy