HackerRank Matching Word & Non-Word Character Solution

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

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

\w
The expression \w will match any word character.
Word characters include alphanumeric characters (azAZ and 09) and underscores (_).

\W
\W
 matches any non-word character.
Non-word characters include characters other than alphanumeric characters (azAZ and 0–9) and underscore (_).

Task

You have a test string S. Your task is to match the pattern xxxXxxxxxxxxxxXxxx.
Here x denotes any word character and X denotes any nonword 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 (_________).

Ezoicreport this adHackerRank Matching Word & Non-Word Character Solutions in Cpp

HackerRank Matching Word & Non-Word Character Solutions in Java

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

HackerRank Matching Word & Non-Word Character Solutions in Python

Regex_Pattern = r"\w{3}\W\w{10}\W\w{3}"	# Do not delete 'r'.
Ezoicreport this ad

HackerRank Matching Word & Non-Word Character Solutions in JavaScript

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

HackerRank Matching Word & Non-Word Character Solutions in PHP

$Regex_Pattern = "/[\w]{3}[\W][\w]{10}[\W][\w]{3}/"; //Do not delete '/'. Replace __________ with your regex. 

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

Next: HackerRank Matching Start & End Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad