473,508 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String Relace

How do i Replace a character with a nul value

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space

Thanks
DAve
Jan 28 '07 #1
11 1355
Realise that you are REMOVING the letter and not replacing it and all shall
be revealed on how to solve this problem ;)

"dave" <dv*****@sbcglobal.netwrote in message
news:88******************@newssvr29.news.prodigy.n et...
How do i Replace a character with a nul value

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space

Thanks
DAve


Jan 28 '07 #2
Hi,

"dave" <dv*****@sbcglobal.netwrote in message
news:88******************@newssvr29.news.prodigy.n et...
How do i Replace a character with a nul value
What u meant with "null" ?

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space
Your code does that, it replace 'a' with a NON space, more eactly it just
remove the 'a'

With what u want to replace it with?
Jan 28 '07 #3
Thanks Daniel...i Feel like a dummy......staring right in front of me.....

"Daniel" <no****@pokercat.co.ukwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Realise that you are REMOVING the letter and not replacing it and all
shall be revealed on how to solve this problem ;)

"dave" <dv*****@sbcglobal.netwrote in message
news:88******************@newssvr29.news.prodigy.n et...
>How do i Replace a character with a nul value

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space

Thanks
DAve



Jan 28 '07 #4
like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space
oString.Remove('a')
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jan 28 '07 #5
Remove works (as has been pointed out), but I frequently use Replace with
empty strings. I think it works with strings, but not chars....
Ethan
"dave" <dv*****@sbcglobal.netwrote in message
news:88******************@newssvr29.news.prodigy.n et...
How do i Replace a character with a nul value

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space

Thanks
DAve


Jan 29 '07 #6
<"Ethan Strauss" <ethan dot strauss at Promega dot com>wrote:
Remove works (as has been pointed out), but I frequently use Replace with
empty strings. I think it works with strings, but not chars....
That's because there's no such thing as an "empty char".

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 29 '07 #7
code snippet

is the below the appropriate way to remove characters insid a sting or is
there a better solution

int iChr;

while ((iChr = oBufferOut.IndexOf('"'))>0)

{

oBufferOut=oBufferOut.Remove(iChr,1);

}

"dave" <dv*****@sbcglobal.netwrote in message
news:88******************@newssvr29.news.prodigy.n et...
How do i Replace a character with a nul value

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space

Thanks
DAve


Feb 9 '07 #8
DaveP <dv*****@sbcglobal.netwrote:
code snippet

is the below the appropriate way to remove characters insid a sting or is
there a better solution

int iChr;

while ((iChr = oBufferOut.IndexOf('"'))>0)
{
oBufferOut=oBufferOut.Remove(iChr,1);
}
Yup - use oBufferOut.Replace ("\"", "");

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 9 '07 #9
Thank Jon
Dave

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
DaveP <dv*****@sbcglobal.netwrote:
>code snippet

is the below the appropriate way to remove characters insid a sting or is
there a better solution

int iChr;

while ((iChr = oBufferOut.IndexOf('"'))>0)
{
oBufferOut=oBufferOut.Remove(iChr,1);
}

Yup - use oBufferOut.Replace ("\"", "");

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Feb 9 '07 #10
use
Replace(strString,'a','NULL')

regards

Apr 10 '07 #11
kshitij kumar <ks**********@discussions.microsoft.comwrote:
use
Replace(strString,'a','NULL')
Which language are you thinking of here? The above isn't valid C#, as
'NULL' isn't a valid character literal - and you'd want to call the
Replace method *on* strString, not with strString as the first
parameter.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 10 '07 #12

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

Similar topics

16
6704
by: Krakatioison | last post by:
My sites navigation is like this: http://www.newsbackup.com/index.php?n=000000000040900000 , depending on the variable "n" (which is always a number), it will take me anywhere on the site......
5
31156
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
9
7987
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
9
3668
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
10
8147
by: Angus Leeming | last post by:
Hello, Could someone explain to me why the Standard conveners chose to typedef std::string rather than derive it from std::basic_string<char, ...>? The result of course is that it is...
37
4652
by: Kevin C | last post by:
Quick Question: StringBuilder is obviously more efficient dealing with string concatenations than the old '+=' method... however, in dealing with relatively large string concatenations (ie,...
2
4760
by: Andrew | last post by:
I have written two classes : a String Class based on the book " C++ in 21 days " and a GenericIpClass listed below : file GenericStringClass.h // Generic String class
2
5042
by: s | last post by:
I'm getting compile errors on the following code: <code> #include <iostream> #include <fstream> #include <list> #include <string> using namespace std;
11
3622
by: Christopher Benson-Manica | last post by:
Let's say I have a std::string, and I want to replace all the ',' characters with " or ", i.e. "A,B,C" -> "A or B or C". Is the following the best way to do it? int idx; while(...
16
4317
by: Steve | last post by:
Hi Guys, I have a string which contains data elements separated by spaces. I also have a function which returns the number of characters from the beginning of the string for a given number of...
0
7223
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,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7489
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...
0
5624
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,...
1
5047
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...
0
4705
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...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
414
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...

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.