Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:15:17+00:00 2026-06-07T23:15:17+00:00

Very simply, I want to assign a variable the value of a single backslash

  • 0

Very simply, I want to assign a variable the value of a single backslash character. The problem is:

var myVar = '\';     // breaks because the backslash escapes the closing quote
var myVar = '\\';    // now myVar has two backslashes

Everything I can find says that you escape a backslash with a backslash, which is what I have always known to be generally true. However, when I run this in IE I get two backslashes instead of one.

Here’s a screenshot of the IE debugger attempting to replace a # with a . This problem occurs anywhere I try to escape a backslash with a string literal – the string.replace() function yields the same error.

screenshot

[Edit]

Thanks for the comments. In the short term I’ll probably use octal or hexadecimal ascii as several people have recommended. But what I would really like is to understand why I can’t just escape the backslash.

Here’s a better screenshot without the string.replace function. Same result.

enter image description here

[/Edit]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:15:18+00:00Added an answer on June 7, 2026 at 11:15 pm

    Turns out @Prusse had it right: it wasn’t a problem escaping the backslash, the problem was that the IE debugger renders '\' as '\\'. In my case I had an underlying problem that behaved the same way a mangled string would have so it took a while to track this down.

    Solution:

    Did you try to alert it? (with alert(myVar))
    -Prusse

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

very simple problem, but i want to see how experts look at it. This
i want to make my own app, and i just very simply want to
I have a very simple configuration for uploading files. I simply want to upload
Very simply I want to fill in the message box that is generated by
So I have this very simply SDL application I want to be able to
I have a very simply problem where I need a div to expand to
I have a small problem with a define. I want to assign it to
This ought to be ridiculously easy. I simply want to print a single element
I'll be very simple: I want to be able to store Java objects from
I want to do a very simple script: just want to find the newest

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.