HackerRank Matching Whitespace & Non-Whitespace Character Solution

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

HackerRank Matching Whitespace & Non-Whitespace Character Solution
HackerRank Matching Whitespace & Non-Whitespace Character 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 Whitespace & Non-Whitespace Character Characters Solutions

\s
\s matches any whitespace character [ \r\n\t\f ].

\S
\S matches any non-white space character.

Task

You have a test string S. Your task is to match the pattern XXxXXxXX
Here, x denotes whitespace characters, and X denotes nonwhite space characters.

Note

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

HackerRank Matching Whitespace & Non-Whitespace Character Solutions in Cpp

HackerRank Matching Whitespace & Non-Whitespace Character Solutions in Java

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

HackerRank Matching Whitespace & Non-Whitespace Character Solutions in Python

Regex_Pattern = r"\S{2}\s\S{2}\s\S{2}"	# Do not delete 'r'.
Ezoicreport this ad

HackerRank Matching Whitespace & Non-Whitespace Character Solutions in JavaScript

var Regex_Pattern = /\S\S\s\S\S\s\S\S/; //Do not delete '/'. Replace __________ with your regex. 

HackerRank Matching Whitespace & Non-Whitespace Character Solutions in PHP

$Regex_Pattern = "/[\S]{2}[\s][\S]{2}[\s][\S]{2}/"; //Do not delete '/'. Replace __________ with your regex. 

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

Next: HackerRank Matching Digits & Non-Digit Characters Solution

Sharing Is Caring

Leave a Comment