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 6585691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:41:43+00:00 2026-05-25T16:41:43+00:00

I still don’t get how to do this. I saw many posts regarding this,

  • 0

I still don’t get how to do this. I saw many posts regarding this, but none of the solutions worked for me.

I have a string called “a\\b”. The result I need is “a\b”. How is this done?

I have a text file which has a database connection string pointing to an instance called – Server\DbInstance

My aim is to do a string replace in the text file — replace “Server\DbInstance” with another value, say “10.11.12.13, 1200”.

So I have:

stringToBeReplaced = @"Server\DbInstance";
newString = @"10.11.12.13, 1200";

This is where the problem starts. My stringToBeReplaced will always be “Server\\DbInstance”, and when I search for this string in my text file, the search fails, as the text file doesn’t have a string “Server\\DbInstance”; instead it has only “Server\DbInstance”. So how do change “Server\\DbInstance” to “Server\DbInstance”?

  • 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-05-25T16:41:44+00:00Added an answer on May 25, 2026 at 4:41 pm

    I suspect your string already actually only contains a single backslash, but you’re looking at it in the debugger which is escaping it for you into a form which would be valid as a regular string literal in C#.

    If print it out in the console, or in a message box, does it show with two backslashes or one?

    If you actually want to replace a double backslash with a single one, it’s easy to do so:

    text = text.Replace(@"\\", @"\");
    

    … but my guess is that the original doesn’t contain a double backslash anyway. If this doesn’t help, please give more details.

    EDIT: In response to the edited question, your stringToBeReplaced only has a single backslash in. Really. Wherever you’re seeing two backslashes, that viewer is escaping it. The string itself doesn’t have two backslashes. Examine stringToBeReplaced.Length and count the characters.

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

Sidebar

Related Questions

I read several posts regarding this but still don't understand how to solve my
I've looked up the functions in the manual, but I still don't get this.
After reading : this I still don't get it. in console: puts Category.joins(:posts) It
I'd already ask about this, but still don't have an answer. I think the
I have looked at this question but still don't understand the difference between Iterable
I have a problem that similar to : this question But I still don't
I have read the documentation for the CI Caching but still don't understand much
I have read some articles on POCO in the enttity framework but still don't
I have installed the VS 2010 SDK but I still don't have the VSIX
I admit...I am posting this question because I still don't have an answer to

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.