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 copied the problem's - and tested against my keyboard's in Chrome's console: '-' === '-' returns true. It is the same character.
The problem, instead, is that - is one of the few characters that have a special meaning inside [] - they define a range of characters, such as [0-9a-f] when we want to match hexadecimals, so you need to either place them at the beginning or the end of the set definition.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strong Password
You are viewing a single comment's thread. Return to all comments →
I copied the problem's
-
and tested against my keyboard's in Chrome's console:'-' === '-'
returnstrue
. It is the same character.The problem, instead, is that
-
is one of the few characters that have a special meaning inside[]
- they define a range of characters, such as[0-9a-f]
when we want to match hexadecimals, so you need to either place them at the beginning or the end of the set definition.