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.
Because the code framework in this challenge uses Matcher.find(), and that returns true if the pattern can match any substring in the target. Without the start and end anchors, any invalid username that also had a valid username inside of itself would get approved.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Valid Username Regular Expression
You are viewing a single comment's thread. Return to all comments →
Because the code framework in this challenge uses
Matcher.find()
, and that returns true if the pattern can match any substring in the target. Without the start and end anchors, any invalid username that also had a valid username inside of itself would get approved.