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.
I made use of the greedy nature of regex. A regex will try to match as much as it can, so ^\w.*\W will get the xxxXxxxxX part of the pattern and the \w{3}$ will get the rest.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Matching Word & Non-Word Character
You are viewing a single comment's thread. Return to all comments →
Had to share mine r"^\w.*\W\w{3}/g.
I made use of the greedy nature of regex. A regex will try to match as much as it can, so ^\w.*\W will get the xxxXxxxxX part of the pattern and the \w{3}$ will get the rest.