Strip single quotes from string

Posted on 2004-09-30
Last Modified: 2008-05-06
Can someone tell me a fast way to strip single quotes from a string?

Of course there is

string temp;
for (int i=0; i<str.length; i++)
   if (str[i] != @'\'')
      temp = str[i];

but is there a better way using regex or something?

Question by:RichardFox

Accepted Solution

kayhustle earned 250 total points
ID: 12192312
Try str.Replace(@"""","").

Author Comment

ID: 12192380
For SINGLE quotes?

Expert Comment

ID: 12192742
str = str.Replace("'", "");

quick and easy.

Expert Comment

ID: 21506825

            public static string StripQuotes ( string s , string quoteChar )
                        return s.Replace ( quoteChar , String.Empty );
            } //eof public static string SripQotes ( string s , string quoteChar)

            public static string StripQuotes ( object o , string quoteChar )
                        string s = o.ToString ();
                        return s.Replace ( quoteChar , String.Empty );
            } //eof public static string SripQotes ( string s , string quoteChar)


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 78
c# LinkButton OnClientClick 2 34
Turn on intranet settings 1 39
Connection String 16 43
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now