Imagine you are writing a sign-up page for a website. At some point, it should check whether the login that the user wants to use is valid. Write a regular expression that checks whether a given character is allowed by the rules of the website.
A character composing a login can be alphanumeric, underscore _, hyphen - or tilde ~ character.
Put your regular expression in the regex variable.
Tip: Remember that the hyphen character is a metacharacter in sets. To strip it of its special meaning, put it in the first or in the last position in your set.