The character ~ is called tilde. And in relation to bash it’s used for regular expressions. The tilde ~ is part of the operator, so you need to use the equal and tilde like =~
If you e.g. have
[[ "txt" =~ pattern ]]
It will perform a regular expression match of your string, in this case txt matching you pattern on the right side. In this example the string needs to be in quote and the pattern is created beforehand. Similar setup is used in Perl and Powershell.