Solved

Ignore a quote.

Posted on 2006-07-21
3
266 Views
Last Modified: 2010-04-16
I have a tough one, I'm replacing a text string with "blank" BUT, the text string contains a quote so I'm getting a build error that is expecting a )..

string results = sb.ToString().Replace("<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd>"","")
I can't escape the quote because then it doesn't replace the striing because it's not exact...

How can I get it to work, any thoughts?
0
Comment
Question by:boukaka
[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
3 Comments
 
LVL 7

Accepted Solution

by:
whatsit2002 earned 500 total points
ID: 17155228
It looks like your quote is in the wrong place. You should put your quotes inside of the brackets like:
<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd">

Not:
<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd>"

So, it looks to me that your issue is not escaped double quotes, but misplaced double quotes. The above code would look like:

string results = sb.ToString().Replace("<PolicyDataSet xmlns=\"http://www.microtrends.net/PolicyDataSet.xsd\">","")

Thanks.

Jason
0
 
LVL 6

Expert Comment

by:dorothy2
ID: 17155333
You wouldn't have this problem if the xmlns attribute had single quotes rather than double.

StringBuilder sb = new StringBuilder("This is a test. <PolicyDataSet xmlns='http://www.microtrends.net/PolicyDataSet.xsd'> This is the end of the test");
Console.WriteLine("Before: " + sb.ToString());
string results = sb.ToString().Replace("<PolicyDataSet xmlns='http://www.microtrends.net/PolicyDataSet.xsd'>","");
Console.WriteLine("After: " + results);


Can you make this change easily? If not, you could use regular expressions to change the double quotes to single quotes before you call Replace().

Dorothy
0
 

Author Comment

by:boukaka
ID: 17155811
I moved the quote and it worked perfectly!!! Thank you so much, I was going insane.
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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

690 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