How to replace *"?test=666&test"* to *"222"* in the following code?

If my code has "?" or "&", it will not work.

```html
<body>
  hello
  <br>
  ?test=666&test

  <script>
    function rp (str, map) {
      for (var i in map) {
        str = str.replace(new RegExp(i, 'g'), map[i]);
      }
      return str;
    }

    document.body.innerHTML = rp(document.body.innerHTML, {
        'hello': '111',
        '?test=666&test': '222'
      });
  </script>
</body>
```