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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:15:08+00:00 2026-05-26T04:15:08+00:00

what can I use to replace the string if its in the following format

  • 0

what can I use to replace the string if its in the following format

   I' have a "car" that runs very well

So basically i have a search function

and if they just type ' it wasnt finding it so i did

mySearchWord.Replace("'", "''") 

and then it found it but now what if there is an ' and " in the same sentence or word, how can i check for both in mySearchWord ?

because for both cases i would do something like

    mySearchWord.Replace("'", "''") 

mySearchWord.Replace("\"", "\"") //have no idea about this one

or something like that, is there a way to do it at once?

I think someone below is pointing me in the right direction, i just need to be able to pass apostrophes or quotation marks to my search but it was throwing an error maube because when passed, just as in sql, you would need to escape a quotation or apostrophe

  • 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-26T04:15:09+00:00Added an answer on May 26, 2026 at 4:15 am

    This actually replaces both at once:

    string text = "I' have a \"car\" that runs very well";
    string pattern = "['\"]";
    var result = Regex.Replace(text, pattern, m => (m.Value == "'") ? "''" : "\"\"");
    

    I should explain.

    This is using a method called Regular Expressions. The pattern variable is the regular expression pattern which is used to match things in the string text. In this case the pattern states that it should match all ' and " characters in the text. The pattern [abc] would match all a, b and c characters.

    Regular Expressions seem complex at first, but is very powerful.

    You find the Regex class in the System.Text.RegularExpressions namespace.

    Here is the documentation for it: http://msdn.microsoft.com/en-us/library/c75he57e(v=VS.100).aspx

    The code m => (m.Value == "'") ? "''" : "\"\"" is a Lambda expression, which is a short hand to the Delegate MatchEvaluator (docs).

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

Sidebar

Related Questions

Why would you use the following? Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ReplaceNullChars(string input) I have searched but can't find
How can I use sed to replace this line char * path_list_[1] = {
Can you use two regex in preg_replace to match and replace items in an
How do I use the sha512 function for PHP? Can I replace all my
You can use SelectFolder() to get a folder or GetOpenFolderitem(filter as string) to get
I am decoding a file using the following method: string outFileName = zfoFileName.Replace(.zfo, _tmp.zfo);
I currently have the following funciton in an oracle database that returns a concatenated
I have a large string variable that is assigned from a database column of
I have a data source that I can not alter , the data source
I have a class [DataContract] public class Car { public bool pbIsHatchBack; string prSt

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.