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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:07:39+00:00 2026-05-25T12:07:39+00:00

Given the string a|bc\de,fg~h,ijk,lm|no\p what is the best way to add a ‘\’ before

  • 0

Given the string “a|bc\de,fg~h,ijk,lm|no\p” what is the best way to add a ‘\’ before the ‘|’ ‘,’ ‘~’ and ‘\’

So the end string would be “a\|bc\de\,fg\~h\,ijk\,lm\|no\p”

What is the best way to do this?

I need this in c#.

Then i also need a way to get this string in JavaScript and remove all extra backslashes.

Thank you in advance.

EDIT

Can any one help me the the javacsript function that will give me back the original string, take off the extra \?

  • 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-25T12:07:39+00:00Added an answer on May 25, 2026 at 12:07 pm

    Regex would be overkill. Use String.Replace Method (String, String):

    string myString = @"a|bc\de,fg~h,ijk,lm|no\p";
    
    myString = myString.Replace("|", "\\|").Replace(",", "\\,").Replace("~", "\\~").Replace("\\", "\\\\");
    

    This produces "a\|bc\\de\,fg\~h\,ijk\,lm\|no\\p"

    There’s probably more than one way to get the string out for JavaScript. It will depend on where you’re generating the string. For illustration purposes, say you’re generating the string in the code behind and putting it in some control (like a hidden field, perhaps) on the client.

    In the client you would get the string and use the Javascript String.Replace method, something like this, assuming str1 is "a\|bc\\de\,fg\~h\,ijk\,lm\|no\\p":

    str1 = str1.Replace("\,", ",");
    str1 = str1.Replace("\|", ",");
    str1 = str1.Replace("\\", "\");
    

    It’s been a while since I’ve done JavaScript, so you may need to escape the backslash with another backslash (like \\).

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

Sidebar

Related Questions

I need to add days to given string date and display calculated date in
I'm in need to modify a given string to contain only alpha numerical characters,
I've been looking for a way to hash a given string in C# that
what would be the regular expression to check if a given string contains atleast
I need to know if a given string is a valid DateTime format string
How can I copy a substring from a given string with start and end
I need to make a method that checks if a given String only consists
Is there a way to determine the display length of a given string (in
What I need is to check whether a given string partially matches a given
Given string s = '(A /something_1)(B /something_2)(C /something_3),/,(D /something_4)(D /something_5)' I would like 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.