Escape as usual:
matches = window.location.hash.match /// \
This will be compiled for this regular expression:
/\
And \# matches # in the JavaScript expression.
You can also use Unicode escape code \u0023 :
matches = window.location.hash.match /// \u0023
But not many people recognize \u0023 as a hash symbol, so \# is probably the best choice.
source share