473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

replace

Etu
Hi,

I have a string:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

how can I use the c.Replace(???, ???) method to have this string:

"'abc' "cde", 'mno' "xyz","
that is, all the backslashes are removed.

Thanks,

Etu

Nov 16 '05 #1
14 3267
In the line of code you wrote:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

there are no backslashes in the string. The backslashes you see are
only a typographical convention that tells the compiler that the
double-quote that follows each backslash is not the double-quote that
ends the string, but that it should instead place a double-quote
character in the string.

The string stored internally after compilation looks like this:

'abc' "cde", 'mno' "xyz",

What are you trying to do in your program and what problems are you
encountering, since backslashes in the string don't appear to be what's
wrong?

Nov 16 '05 #2
string c = "'abc' \"cde\", 'mno' \"xyz\",";
string clearString = c.Replace('\\', ' '); // You must type backslash twice

That's All

Hopes This Helps

"Etu" <et*****@yahoo. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi,

I have a string:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

how can I use the c.Replace(???, ???) method to have this string:

"'abc' "cde", 'mno' "xyz","
that is, all the backslashes are removed.

Thanks,

Etu

Nov 16 '05 #3
Etu
Thanks Bruce!

The problem I have is actually my program first reads some strings
(with \t, \" and so on) from an XML file and writes these strings to an
Excel file. After the Excel file is saved, \t becomes a space and \"
becomes ". Then when my program later reads the strings from the Excel
file, it doesn't think the strings are the same as those in the XML
file.

That is why I was trying to modify the strings from the XML file by
getting rid of the backslashes - try to do the same thing that Excel
does, but could not find a way to do so.

Thanks

Bruce Wood wrote:
In the line of code you wrote:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

there are no backslashes in the string. The backslashes you see are
only a typographical convention that tells the compiler that the
double-quote that follows each backslash is not the double-quote that
ends the string, but that it should instead place a double-quote
character in the string.

The string stored internally after compilation looks like this:

'abc' "cde", 'mno' "xyz",

What are you trying to do in your program and what problems are you
encountering, since backslashes in the string don't appear to be what's wrong?


Nov 16 '05 #4
Etu
Thanks SerhaD. However, I tried your code but could not get what I
want.

Thanks

SerhaD Inanli wrote:
string c = "'abc' \"cde\", 'mno' \"xyz\",";
string clearString = c.Replace('\\', ' '); // You must type backslash twice
That's All

Hopes This Helps

"Etu" <et*****@yahoo. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi,

I have a string:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

how can I use the c.Replace(???, ???) method to have this string:

"'abc' "cde", 'mno' "xyz","
that is, all the backslashes are removed.

Thanks,

Etu


Nov 16 '05 #5

"SerhaD Inanli" <se**********@h otmail.com> wrote in message
news:eV******** ******@TK2MSFTN GP14.phx.gbl...
string c = "'abc' \"cde\", 'mno' \"xyz\",";
string clearString = c.Replace('\\', ' '); // You must type backslash twice

Yes but will this make any difference... to the out put... c and clearString
both are same as you out them...???

That's All

Hopes This Helps

"Etu" <et*****@yahoo. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi,

I have a string:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

how can I use the c.Replace(???, ???) method to have this string:

"'abc' "cde", 'mno' "xyz","
that is, all the backslashes are removed.

Thanks,

Etu


Nov 16 '05 #6
Etu
Thanks Bruce!

The problem I have is actually my program first reads some strings
(with \t, \" and so on) from an XML file and writes these strings to an
Excel file. After the Excel file is saved, \t becomes a space and \"
becomes ". Then when my program later reads the strings from the Excel
file, it doesn't think the strings are the same as those in the XML
file.

That is why I was trying to modify the strings from the XML file by
getting rid of the backslashes - try to do the same thing that Excel
does, but could not find a way to do so.

Thanks

Bruce Wood wrote:
In the line of code you wrote:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

there are no backslashes in the string. The backslashes you see are
only a typographical convention that tells the compiler that the
double-quote that follows each backslash is not the double-quote that
ends the string, but that it should instead place a double-quote
character in the string.

The string stored internally after compilation looks like this:

'abc' "cde", 'mno' "xyz",

What are you trying to do in your program and what problems are you
encountering, since backslashes in the string don't appear to be what's wrong?


Nov 16 '05 #7
Etu
Thanks SerhaD. However, I tried your code but could not get what I
want.

Thanks

SerhaD Inanli wrote:
string c = "'abc' \"cde\", 'mno' \"xyz\",";
string clearString = c.Replace('\\', ' '); // You must type backslash twice
That's All

Hopes This Helps

"Etu" <et*****@yahoo. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi,

I have a string:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

how can I use the c.Replace(???, ???) method to have this string:

"'abc' "cde", 'mno' "xyz","
that is, all the backslashes are removed.

Thanks,

Etu


Nov 16 '05 #8

"SerhaD Inanli" <se**********@h otmail.com> wrote in message
news:eV******** ******@TK2MSFTN GP14.phx.gbl...
string c = "'abc' \"cde\", 'mno' \"xyz\",";
string clearString = c.Replace('\\', ' '); // You must type backslash twice

Yes but will this make any difference... to the out put... c and clearString
both are same as you out them...???

That's All

Hopes This Helps

"Etu" <et*****@yahoo. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi,

I have a string:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

how can I use the c.Replace(???, ???) method to have this string:

"'abc' "cde", 'mno' "xyz","
that is, all the backslashes are removed.

Thanks,

Etu


Nov 16 '05 #9
private void RegEx_Click(obj ect sender, System.EventArg s e)

{

string c = "'abc' \"cde\", 'mno' \"xyz\",";

try

{

textBox1.Text = c.Replace('\\', ' '); // Second parameter is a blank char

}

catch(Exception ex)

{
MessageBox.Show (ex.Message);

}

}

and Result is = 'abc' "cde", 'mno' "xyz",

I Tried several times , do u get different output or Error ?

"Etu" <et*****@yahoo. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Thanks SerhaD. However, I tried your code but could not get what I
want.

Thanks

SerhaD Inanli wrote:
string c = "'abc' \"cde\", 'mno' \"xyz\",";
string clearString = c.Replace('\\', ' '); // You must type backslash

twice

That's All

Hopes This Helps

"Etu" <et*****@yahoo. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hi,

I have a string:

string c = "'abc' \"cde\", 'mno' \"xyz\",";

how can I use the c.Replace(???, ???) method to have this string:

"'abc' "cde", 'mno' "xyz","
that is, all the backslashes are removed.

Thanks,

Etu

Nov 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3022
by: Craig Keightley | last post by:
Can these lines of sql statements be consolidated into one sql statement (possibly using reg exps??) BEGIN CODE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Update applications Set news_article = replace(news_article, '<FONT face="Times New Roman" color=#000000 size=3>', ''); Update applications Set news_article = replace(news_article, '<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">', ''); Update...
12
8153
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so that the apostrophe is automatically replace with two '' . Reason being--SQL Server does not like apostrophes being sent to database. I've tried to do this on the server side in the SQL area of the ASP page by writing a function (with some great...
6
5660
by: Danny | last post by:
I need an asp command to strip out from a string all extra punctuation such as apostrophe, comma, period, spaces dashes, etc etc and just leave the letters. Can anybody give me some ideas? Thanks
9
9145
by: Peter Row | last post by:
Hi, I know this has been asked before, but reading the threads it is still not entirely clear. Deciding which .Replace( ) to use when. Typically if I create a string in a loop I always use a StringBuilder. At present I am porting a VB6 webclass app to VB.NET and therefore I am trying to make it as efficent as possible via the new functionality of VB.NET.
4
3838
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said, that the split method and the regex.replace method was better than the string.replace method and replace function. I did not believe that.
3
3312
by: Goran Djuranovic | last post by:
Hi all, I ran into a problem where my XMLTextReader fails on .Read() when I have "<" character in one of the attribute's values. What I am trying to do is replace illegal characters ("<", "&" , etc.) with legal stuff ("&lt;", "&amp;", etc.), before I send the XML text to a SQL Server stored procedure. Currently, I am using XMLTextReader and StringWriter to do this, here is the piece of code that fails:...
3
16914
by: TOXiC | last post by:
Hi everyone, First I say that I serched and tryed everything but I cannot figure out how I can do it. I want to open a a file (not necessary a txt) and find and replace a string. I can do it with: import fileinput, string, sys fileQuery = "Text.txt" sourceText = '''SOURCE'''
6
15579
by: JackpipE | last post by:
Here is my replace query and I need to run this on every column in my table. Right now I manually enter the column name (_LANGUAGES_SPOKEN) but this is time consuming and would like to automate this process as much as possible. Update PROFILE SET LANGUAGES_SPOKEN = replace(cast(_LANGUAGES_SPOKEN as nvarchar(255)),char(13)+char(10),':') Thanks,
5
9256
by: V S Rawat | last post by:
I was trying to use back-to-back replace functions to convert a url: str1 = str.replace("%2F","/").replace("%3F","?").replace("%3D","=").replace("%2 6","&"); It didn't replace all 4 types of strings. Then, I googled and found this suggestion of some JavaScript Tutorials, so I used replace with a regex with a global switch:
15
1893
by: =?Utf-8?B?TWlrZSAiWU9fQkVFIiBC?= | last post by:
I have a text file that contains about 8 to 10 text sequences that I need to replace. I want to search and replace all 8 to 10 text sequence anytime I run this script Here is what I have so far. Const ForReading = 1 Const ForWriting = 2
0
8420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.