I wish to replace all the occurrances of " with " within a string.
I have tried using myString.Replace("\"", """), but this does not work
Any suggestions will be greatly appreciated
Thanks 6 6575
Dan wrote: I wish to replace all the occurrances of " with " within a string.
I have tried using myString.Replace("\"", """), but this does not work
Do not make the mistake to do this:
string foo = "lalalla\"";
foo.Replace("\"", """);
this will not change 'foo'. do:
string foo = "lalalla\"";
foo = foo.Replace("\"", """);
FB
--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Does not work? Could you be a bit more specific? Runtime error or compile
error?
I assume it's a runtime error as the code seems fine.
are you forgetting to assign the result? myString = myString.Replace(...);
Lars Moastuen
On Fri, 6 Aug 2004 12:35:34 +0100, Dan <dan.parker@_nospam_pro-bel.com>
wrote: I wish to replace all the occurrances of " with " within a string.
I have tried using myString.Replace("\"", """), but this does not work
Any suggestions will be greatly appreciated
Thanks
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
I've tried your code, and:
String myString = "Hello \"World\"";
Console.WriteLine(myString);
Console.WriteLine(myString.Replace("\"", """));
Works fine.
Probably the error's somewhere else.
Niki
"Dan" <dan.parker@_nospam_pro-bel.com> wrote in
news:Oc*************@TK2MSFTNGP12.phx.gbl... I wish to replace all the occurrances of " with " within a string.
I have tried using myString.Replace("\"", """), but this does not
work Any suggestions will be greatly appreciated
Thanks
hi,
string mystring ="asdasdasd\"\"asdasd\"asdsd\"";
mystring.Replace("\"",""");
use this thing.
hi,
i am really sorry. my previous post is wrong.
this is the correct answer.
In your code you are trying to replace few characters. That's fine.
myString.Replace("\"", """),
But you need to know one importent thing in String class is that
string is immutable. That means if you try to update one variable of that
type string it won't update the real value.
string SSS=myString.Replace("\"", """),
Now you will get the result on SSS.
If you try to print the value of myString it won't change the old value.
Try this example and try to view the value of myString after printing SSS.
Sreejith S S Nair <Sr************@discussions.microsoft.com> wrote: string mystring ="asdasdasd\"\"asdasd\"asdsd\""; mystring.Replace("\"",""");
use this thing.
No, don't. The second line is effectively a no-op, because you're not
using the returned value. Calling Replace doesn't change the actual
string itself, it returns a new string with the replacement having been
performed.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jakanapes |
last post by:
Hi all,
I'm looking for a way to scan a block of text and replace all the
double quotes (") with single quotes (').
I'm using PHP to pull text out of a mySQL table and then feed the text
into...
|
by: ribchr00 |
last post by:
Hi all,
I would like to replace line breaks such '+' with '<br />'. Easy
task. Problems start when I try to only replace lines that do not end
with HTML tags.
I tried preg_replace("/+/", "<br...
|
by: Xah Lee |
last post by:
i have a bunch of java files that has spaced-out formatting that i
want to get rid of. I want to replace two end of line characters by
one end of line characters. The files in question is unix, and...
|
by: Matt |
last post by:
I have 2 questions:
1. strlen returns an unsigned (size_t) quantity. Why is an unsigned
value more approprate than a signed value? Why is unsighned value less
appropriate?
2. Would there...
|
by: Ryan Taylor |
last post by:
Hi.
I have some code that dynamically generates a PDF and spits this content
directly to the web browser. I use HTMLDoc to create the Pdf's from html. So
the user can click on a button "Print...
|
by: TobyD |
last post by:
I am a beginner programmer in VB and need help. If I have a string with a
return, how do I exchange the return with a return and tab?
Currently I am entering a string with EnterKeyBehavior...
|
by: relient |
last post by:
Question: Why can't you access a private inherited field from a base
class in a derived class? I have a *theory* of how this works, of
which, I'm not completely sure of but makes logical sense to...
|
by: Milsnips |
last post by:
Hi there,
i'm trying to do a string replace on something like the following
string MyString = myinput;
myinput = myinput.Replace("src="../content/","http://www.site.com/content/")
but, the...
|
by: Choi |
last post by:
Hi !
I wonder how I can replace a quote by a "\n" in a string.
For example my string is rrrrrrr'ttttttt and I want to obtain :
rrrrrrr
ttttttt
I tried the function find, but I don't know...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |