Hello Programmers, In this post, you will learn how to solve HackerRank Branch Reset Group Solution. This problem is a part of the Regex HackerRank Series.
HackerRank Branch Reset Group Solution
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.
You have a test string S.
Your task is to write a regex which will match S, with following condition(s):
- S consists of 8 digits.
- S must have “—“, “-“, “.” or “:” separator such that string S gets divided in 4 parts, with each part having exactly two digits.
- S string must have exactly one kind of separator.
- Separators must have integers on both sides.
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 (
HackerRank Branch Reset Group Solution in Cpp
HackerRank Branch Reset Group Solution in Java
HackerRank Branch Reset Group Solution in Python
HackerRank Branch Reset Group Solution in PHP
$Regex_Pattern = '/^\d\d(?|(---)|(-)|(.)|(:))\d\d\1\d\d\1\d\d$/'; //Do not delete '/'. Replace __________ with your regex.