Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1036

RegExp and backslash

$
0
0

I'm trying to replace in a string any backslash (\) with a normal slash(/).
The string .replace method requires a RegExp as parameter. My current code is the following:

var regexBackslash = new RegExp("\\\\");
while(sPath.search(regexBackslash)>=0){
   sPath=sPath.replace(regexBackslash,"/");
}

This works but the RegExp("\\\\") part acts odd in the script IDE as any comment afterwards (with //) is colored like its code.
Do I have to escape the the backslash differently?


Viewing all articles
Browse latest Browse all 1036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>