HackerRank Matching Digits & Non-Digit Characters Solution

Hello Programmers, In this post, you will know how to solve the HackerRank Matching Digits & Non-Digit Characters Solution. This problem is a part of the Regex HackerRank Series.

HackerRank Matching Digits & Non-Digit Characters Solution
HackerRank Matching Digits & Non-Digit Characters Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

HackerRank Matching Digits & Non-Digit Characters Solutions

\d
The expression \d matches any digit [0 – 9].

\D
The expression \D matches any character that is not a digit.

Task

You have a test string S. Your task is to match the pattern xxXxxXxxxx
Here x denotes a digit character, and X denotes a nondigit character.

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 (_________).

HackerRank Matching Digits & Non-Digit Characters Solutions in Cpp

HackerRank Matching Digits & Non-Digit Characters Solutions in Java

public class Solution {    
    public static void main(String[] args) {
        
        Regex_Test tester = new Regex_Test();
        tester.checker("(\\d){2}\\D(\\d){2}\\D(\\d){4}"); // Use \\ instead of using \ 
    
    }
}

HackerRank Matching Digits & Non-Digit Characters Solutions in Python

Regex_Pattern = r"\d{2}\D\d{2}\D\d{4}"	# Do not delete 'r'.
Ezoicreport this ad

HackerRank Matching Digits & Non-Digit Characters Solutions in JavaScript

var Regex_Pattern = /[0-9]{2}[^0-9][0-9]{2}[^0-9][0-9]{4}/; //Do not delete '/'. Replace __________ with your regex. 

HackerRank Matching Digits & Non-Digit Characters Solutions in PHP

$Regex_Pattern = "/[0-9]{2}[^0-9]{1}[0-9]{2}[^0-9]{1}[0-9]{4}/"; //Do not delete '/'. Replace __________ with your regex. 

Disclaimer: This problem (Matching Digits & Non-Digit Characters) is generated by HackerRank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: HackerRank Matching Anything But a Newline Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad