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. Backreferences
  4. Branch Reset Groups

Branch Reset Groups

Problem
Submissions
Leaderboard
Discussions
Editorial

NOTE - Branch reset group is supported by Perl, PHP, Delphi and R.

A branch reset group consists of alternations and capturing groups. (?|(regex1)|(regex2))
Alternatives in branch reset group share same capturing group.


Task

You have a test string .
Your task is to write a regex which will match , with following condition(s):

  • consists of 8 digits.
  • must have "---", "-", "." or ":" separator such that string gets divided in parts, with each part having exactly two digits.
  • string must have exactly one kind of separator.
  • Separators must have integers on both sides.

Valid

12-34-56-78
12:34:56:78
12---34---56---78
12.34.56.78

Invalid

1-234-56-78
12-45.78:10

Note

This is a regex only challenge. You are not required to write any code.
You only have to fill the regex pattern in the blank (_________).

Author

[deleted]

Difficulty

Easy

Max Score

20

Submitted By

19355

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