For example if we want to replace two characters we can use replace method by
str = new string(vikasraj)
str = str.replace(k,"l");
The above will replace vikas to vilas where a single replace takes place. Whereas to makes the replace globally we can use /g along with the above replace format
str = str.replace(/a/g,"e")
This will replace vikasraj to vikesrej. If we want to replace the special charaters it will not works with the above replacement format. There we can use the regular expressions where it can be used globally also.
str = new string("http://hiox.org+bypass+addscraps.php")
str = str.replace(/\+/g,"/")
The result would be http://hiox.org/bypass/addscraps.php.Here regular expression plays its role in replacing the slash with plus sign.