[Javascript] Split

Andrew Gibson andyg at ihug.co.nz
Thu Dec 12 17:11:06 CST 2002


Trying to split string with "\"

Subject: Re: [Javascript] Split
> Try: var t=txt.split("\\")

Many thanks for the help on this. But when I try the following code

<script>

  var txt="test\test"
  var t=txt.split("\\")
   alert(t.length)
   alert(t[0])

 </script>

The alerts return  1 for the length of the array
 and value of the first element is "test   est"

That must be something to do with \t [est] in the string but I thought the
\\ would escape the special \ character.

Im using ie6.0 on pc.

Andrew Gibson








More information about the Javascript mailing list