We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Matching Whitespace & Non-Whitespace Character
Matching Whitespace & Non-Whitespace Character
Sort by
recency
|
125 Discussions
|
Please Login in order to post a comment
I hate to be so pedantic, but these task descriptions are pretty bad. For instance, would imply that every is the same non-whitespace character and every is the same whitespace character.
The problem description should be written differently or come with some minimally-reproducible examples so we can infer what the challenge is really asking for.
r"(\S{2}\s){2}\S{2}"
got a working regex but I think I comlicated it ^(([\S][\s])([\S]{2}[\s])([\S]*))$
In my opinion, either the problem statement is ambigous or it is inconsistent with the test cases.
Being an excercise to introduce the metacharacters \S and \s, the resolution should be simple and straightfoward, that is /^\S\S\s\S\S\s\S\S$/
However that expression does not pass some of the test cases. Namely those with multiple whitespaces or non-whitespaces. Thus the solution should be /^\S\S+\s+\S\S+\s+\S\S+$/ which also do not work. So said!!