Hi,
I need to detect the presence of a backslash character in a string and
escape that character using the replace function. I seem to be able to do
this with any character except the backslash character. The replace
function is ignoring the presence of the baclslash. The simple code I am
using is below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled </title>
<script language="JavaS cript1.2">
function FileName(){
filenameTest = 'hello \ goodbye'
alert(filenameT est.replace('\\ ','\\\\'))
}
</script>
</head>
<body onload="FileNam e()">
</body>
</html>
Like I say, if I try to replace any other character it is fine but it seems
not to be able to detect the backslash in the variable filenameTest
Any ideas?
Thanks,
Stephen
I need to detect the presence of a backslash character in a string and
escape that character using the replace function. I seem to be able to do
this with any character except the backslash character. The replace
function is ignoring the presence of the baclslash. The simple code I am
using is below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled </title>
<script language="JavaS cript1.2">
function FileName(){
filenameTest = 'hello \ goodbye'
alert(filenameT est.replace('\\ ','\\\\'))
}
</script>
</head>
<body onload="FileNam e()">
</body>
</html>
Like I say, if I try to replace any other character it is fine but it seems
not to be able to detect the backslash in the variable filenameTest
Any ideas?
Thanks,
Stephen
Comment