Results 1 to 2 of 2
  1. #1

    Question 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

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •