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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:52:15+00:00 2026-06-14T21:52:15+00:00

In this variable, i would like to add some \ before every ‘. string

  • 0

In this variable, i would like to add some \ before every ‘.

string html = 
    "<a href=\"annee-prochaine.html\">Calendrier de l'annee prochaine</a>"

html = html.Replace("'", "\'"); //No change
html = html.Replace("\'", "\'"); //No change

html = html.Replace("\'", "\\'");
//html => <a href=\"annee-prochaine.html\">Calendrier de l\\'annee prochaine</a>
html = html.Replace("\'", @"\'");
//html => <a href=\"annee-prochaine.html\">Calendrier de l\\'annee prochaine</a>

I would like to get that after Replace :

//html => <a href=\"annee-prochaine.html\">Calendrier de l\'annee prochaine</a>

Any ideas ?

Thanks!

  • 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-14T21:52:16+00:00Added an answer on June 14, 2026 at 9:52 pm

    I strongly suspect that you’re looking at the strings in the debugger, which is why you’re seeing doubled backslashes.

    This version is absolutely fine:

    html = html.Replace("\'", "\\'");
    

    (The one using the verbatim string literal would be fine too.) Rather than looking at it in the debugger, log it or just serve it, and everything should be fine.

    The fact that you’re seeing it for the double-quote as well is further evidence of this. For example, this string:

    string html = "<a href=\"anne...";
    

    … does not contain a backslash, but your diagnostics are showing it, which is what I’d expect in a debugger.

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

Sidebar

Related Questions

I have this string stored in a variable: IN=bla@some.com;john@home.com Now I would like to
I would declare an empty String variable like this: string myString = string.Empty; Is
I would like to add some multitouch features to my javascript application when it
How would one expose static variables like this class MyClass: X = 1 Y
I have this variable defined in my web.config file : <appSettings> <add key =version
I would like to display popovers with UITableView 's as content (this works) on
I am using Agile Toolkit for some development and would like to extend the
I have a HTML form that has a selection drop down. I would like
Given this variable in tcsh: set i = ~/foo/bar.c how can I get just
I have this variable: $timestamp = strftime(%Y-%m-%d %h:%M:%S %a, time ()); I simply want

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.