```RegExp("^"+from, 'g'); ``` won't work as it will only check if content starts with from  content. For example:
```javascript
foo('<p>/static/foo.png</p>', '/static/', '/anotherprefix/')
"<p>/static/foo.png</p>"
```
but actual result should be:
```javascript
foo('<p>/static/foo.png</p>', '/static/', '/anotherprefix/')
"<p>/anotherprefix/foo.png</p>"
```

The approach I wanted to use was to replace all occurrences until unless if given string (to be replaced) is inside an absolute url. For example replace ```/static/``` should work for following strings:
* ```"/static/foo.png"```
* ```"<p>/static/foo.png</p>"```
* ```"<p>sample static url [/static/foo.png]</p>"```
* ```"static url = '/static/foo.png'"```

Replace ```/static/``` should not work for following strings:
* ```"http://localhost.com/static/foo.png"```
* ```"http://localhost.com/data-dir/static/foo.png"```
* ```"https://www.localhost.org/data-dir/static/foo.png"```