In this post, we will solve Matching Word & Non-Word Character HackerRank Solution. This problem (Matching Word & Non-Word Character) is a part of HackerRank Regex series.
The expression \w will match any word character.
Word characters include alphanumeric characters (a–z, A–Z and 0–9) and underscores (_).
\W matches any non-word character.
Non-word characters include characters other than alphanumeric characters (a–z, A–Z and 0–9) and underscore (_).
You have a test string S. Your task is to match the pattern xxxXxxxxxxxxxxXxxx.
Here x denotes any word character and X denotes any non-word character.
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 (
Solution – Matching Word & Non-Word Character – HackerRank Solution
Regex_Pattern = r"\w\w\w\W\w\w\w\w\w\w\w\w\w\w\W\w\w\w" # Do not delete 'r'. import re print(str(bool(re.search(Regex_Pattern, input()))).lower())
Note: This problem (Matching Word & Non-Word Character) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.