I need to replace the spaces inside a string with the % symbol but I'm having some issues, what I tried is:

```
imageUrl = imageUrl.replace(' ', "%20");

```

But It gives me an error in the replace function.

Then:

```
imageUrl = imageUrl.replace(' ', "%%20");

```

But It still gives me an error in the replace function.

The I tried with the unicode symbol:

```
imageUrl = imageUrl.replace(' ', (char) U+0025 + "20");

```

But it still gives error.

Is there an easy way to do it?