In this post, we will solve Matching Whitespace & Non-Whitespace Character HackerRank Solution. This problem (Matching Whitespace & Non-Whitespace Character) is a part of HackerRank Regex series.
Objective
\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 non-white 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 (_________
).
Solution – Matching Whitespace & Non-Whitespace Character – HackerRank Solution
Python
Regex_Pattern = r"\S\S\s\S\S\s\S\S" # Do not delete 'r'. import re print(str(bool(re.search(Regex_Pattern, input()))).lower())
Note: This problem (Matching Whitespace & Non-Whitespace Character) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.