Solved

Strip single quotes from string

Posted on 2004-09-30
4
994 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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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