Solved

Strip single quotes from string

Posted on 2004-09-30
4
991 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
Comment Utility
Try str.Replace(@"""","").
0
 

Author Comment

by:RichardFox
Comment Utility
For SINGLE quotes?
0
 
LVL 9

Expert Comment

by:msdixon
Comment Utility
str = str.Replace("'", "");

quick and easy.
0
 

Expert Comment

by:yordan_georgiev
Comment Utility

            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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), 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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

12 Experts available now in Live!

Get 1:1 Help Now