if you cut and paste a path from windows explorer
\\myshare\mydir\mydoc.txt into a form textbox, you can use the
following code to transform it into something usable by a browser:
mytxt = document.myForm.myTextBox.value;
mytxt = mytxt.replace(/\134/g,"/");
\134 is the octal representation of a backslash as a regular
expression. the g is required to replace all instances of the
backslash.
> mytxt = document.myForm.myTextBox.value;
> mytxt = mytxt.replace(/\134/g,"/");
>
> \134 is the octal representation of a backslash as a regular
> expression. the g is required to replace all instances of the
> backslash.
Why not simply
mytxt = mytxt.replace(/\\/g,"/");
? I am not sure octal escape sequences in regular expression patterns
are standardized and support anywhere.
--
Martin Honnen
http://JavaScript.FAQTs.com/