Solved

Strip single quotes from string

Posted on 2004-09-30
4
995 Views
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?

thx
0
Comment
Question by:RichardFox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

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

Author Comment

by:RichardFox
ID: 12192380
For SINGLE quotes?
0
 
LVL 9

Expert Comment

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

quick and easy.
0
 

Expert Comment

by:yordan_georgiev
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)

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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