Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1003
  • Last Modified:

Strip single quotes from string

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?

thx
0
RichardFox
Asked:
RichardFox
1 Solution
 
kayhustleCommented:
Try str.Replace(@"""","").
0
 
RichardFoxAuthor Commented:
For SINGLE quotes?
0
 
msdixonCommented:
str = str.Replace("'", "");

quick and easy.
0
 
yordan_georgievCommented:

            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)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now