Results 1 to 2 of 2
Thread: Javascript: match backslash
-
01-31-2006, 05:35 PM #1Newbie
- Join Date
- Jan 2005
- Posts
- 13
Javascript: match backslash
Why doesn't the below match the backslash in 'str' and split it??
This is driving me crazy.
<script type="text/javascript">
var str="before\after"
document.write(str.split("\\"))
</script>
Thanks,
Paul
-
01-31-2006, 11:27 PM #2Web Hosting Master
- Join Date
- Sep 2002
- Location
- Illinois
- Posts
- 2,307
JavaScript interprets \a as an escape character, it won't work it this case. Put extra \ and you will get wanted result.
<script type="text/javascript">
var str="before\\after"
document.write(str.split("\\"))
</script>How's my programming? Call 1-800-DEV-NULL