Assuming you're using the URL as an argument to a CGI, consider an alternate encoding of the link, such as URL-encoding. Then, on the receiving end, simply URL-decode the argument. Then use \Q and \E in the regex to block certain characters from being interpreted as regex meta-characters.