EasyBuild has a more updated version of this:

```python
    def escape_special(string):
        return re.sub(r"([\+\?\(\)\[\]\*\.\\\$])" , r"\\\1", string)
```