HackerRank Matching Specific Characters Solution

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

HackerRank Matching Specific Characters Solution
HackerRank Matching Specific 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 Specific Characters Solutions

[]
The character class [ ] matches only one out of several characters placed inside the square brackets.

Task

You have a test string S.
Your task is to write a regex that will match S with following conditions:

  • S must be of length: 6
  • First character: 12 or 3
  • Second character: 12 or 0
  • Third character: xs or 0
  • Fourth character: 30 , A or a
  • Fifth character: xs or u
  • Sixth character: . or ,

Note

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

HackerRank Matching Specific Characters Solutions in Cpp

HackerRank Matching Specific Characters Solutions in Java

public class Solution {    
    public static void main(String[] args) {
        
        Regex_Test tester = new Regex_Test();
        tester.checker("^[123][120][xs0][30Aa][xsu][\\.\\,]$"); // Use \\ instead of using \ 
    
    }
}

HackerRank Matching Specific Characters Solutions in Python

Regex_Pattern = r'^[1-3][0-2][xs0][30Aa][xsu][.,]$'	# Do not delete 'r'.
Ezoicreport this ad

HackerRank Matching Specific Characters Solutions in JavaScript

var Regex_Pattern = /^[123][120][xs0][30Aa][xsu][.,]$/; //Do not delete '/'. Replace __________ with your regex. 

HackerRank Matching Specific Characters Solutions in PHP

$Regex_Pattern = "/^[123][120][xs0][30Aa][xsu][.,]$/"; //Do not delete '/'. Replace __________ with your regex. 

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

Next: HackerRank Matching Word Boundaries Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad