473,561 Members | 3,340 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String.Replace dont work?

dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"

pp.Replace("{", Nothing)
pp.Replace("}", Nothing)
pp.Replace("X=" , Nothing)
pp.Replace("Y=" , Nothing)

after this, pp is exactly the same as before??!!

Crirus

Nov 20 '05 #1
9 2143
I think you must do
pp = pp.Replace("{", Nothing)
pp = pp.Replace("}", Nothing)
pp = pp.Replace("X=" , Nothing)
pp = pp.Replace("Y=" , Nothing)

function replace (string) as string
lobrys
"Crirus" <Cr****@datagro up.ro> a écrit dans le message de
news:ez******** *****@tk2msftng p13.phx.gbl...
dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"

pp.Replace("{", Nothing)
pp.Replace("}", Nothing)
pp.Replace("X=" , Nothing)
pp.Replace("Y=" , Nothing)

after this, pp is exactly the same as before??!!

Crirus

Nov 20 '05 #2
Cor
Crirus,
I Thought

Dim Crirus as String = pp.Replace(.... ............... .
(String member)
or just
Dim Crirus as String = Replace(
(String Function)

I hope this helps a little bit?

Cor
Nov 20 '05 #3
Sorry, solved...I have to assign it back to pp

"Crirus" <Cr****@datagro up.ro> wrote in message
news:ez******** *****@tk2msftng p13.phx.gbl...
dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"

pp.Replace("{", Nothing)
pp.Replace("}", Nothing)
pp.Replace("X=" , Nothing)
pp.Replace("Y=" , Nothing)

after this, pp is exactly the same as before??!!

Crirus

Nov 20 '05 #4
* "Cor" <no*@non.com> scripsit:
Dim Crirus as String = pp.Replace(.... ............... .
(String member)
or just
Dim Crirus as String = Replace(
(String Function)


Member of 'Microsoft.Visu alBasic.Strings '.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #5
Crirus,
In addition to your & the other comments about need to assign the result
back to a variable.

With four replaces in a row as you have, I would consider using
StringBuilder.R eplace instead of String.Replace.

Something like:

Imports System.Text

dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"
Dim sb As New StringBuilder(p p)
sb.Replace("{", Nothing)
sb.Replace("}", Nothing)
sb.Replace("X=" , Nothing)
sb.Replace("Y=" , Nothing)

pp = sb.ToString()

Especially if I was using string concatenation to build pp in the first
place. As I would use StringBuild.App end to build the string, then use the
above Replace statements to clean it.

Dim sb As New StringBuilder(p p)

sb.Append(pt1.T oString())
sb.Append(pt2.T oString())
sb.Append(pt3.T oString())

...
sb.Replace("{", Nothing)
...

Hope this helps
Jay

"Crirus" <Cr****@datagro up.ro> wrote in message
news:ez******** *****@tk2msftng p13.phx.gbl... dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"

pp.Replace("{", Nothing)
pp.Replace("}", Nothing)
pp.Replace("X=" , Nothing)
pp.Replace("Y=" , Nothing)

after this, pp is exactly the same as before??!!

Crirus

Nov 20 '05 #6
Is faster that way? Any other advantages?

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Crirus,
In addition to your & the other comments about need to assign the result
back to a variable.

With four replaces in a row as you have, I would consider using
StringBuilder.R eplace instead of String.Replace.

Something like:

Imports System.Text

dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"


Dim sb As New StringBuilder(p p)
sb.Replace("{", Nothing)
sb.Replace("}", Nothing)
sb.Replace("X=" , Nothing)
sb.Replace("Y=" , Nothing)

pp = sb.ToString()

Especially if I was using string concatenation to build pp in the first
place. As I would use StringBuild.App end to build the string, then use the
above Replace statements to clean it.

Dim sb As New StringBuilder(p p)

sb.Append(pt1.T oString())
sb.Append(pt2.T oString())
sb.Append(pt3.T oString())

...
sb.Replace("{", Nothing)
...

Hope this helps
Jay

"Crirus" <Cr****@datagro up.ro> wrote in message
news:ez******** *****@tk2msftng p13.phx.gbl...
dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"

pp.Replace("{", Nothing)
pp.Replace("}", Nothing)
pp.Replace("X=" , Nothing)
pp.Replace("Y=" , Nothing)

after this, pp is exactly the same as before??!!

Crirus


Nov 20 '05 #7
Cor
Hi Crirus,

To give my opinion to add to the message from Jay B. because I fully agree
with him.

I don't think there is a big advantages in this example.

But the advantage is to get used to the Stringbuilder because the building
of strings is always been in every computer language a time spending part
and has never been really good implemented.

Now we have a better way, so lets use it than we take it the next time
automaticly.

I was glad with this message from Jay B.

I will try to use it next time when I give an example.

Just a thought.

Cor
Nov 20 '05 #8
Crirus,
It really depends on how you are building the string.

For four simple replacements. I would expect it to be a wash (the same
time).

However if you have a series of string concatenations before the
replacements, then yes I would expect the StringBuilder to be faster.

The other major advantage, each time you call string.Replace you are
creating a new temporary string object, if you do 4 replacements you will
have 4 temporary string objects.

With the StringBuilder you will have 1 temporary stringbuilder object, so
you are saving 3 objects that the GC needs to worry about. Would I worry
about just the 3 objects, probably not. However if I decided I needed 10
replacements or 20 replacements I think you will find that the StringBuilder
quickly becomes the better deal...

Hope this helps
Jay

"Crirus" <Cr****@datagro up.ro> wrote in message
news:eZ******** ******@TK2MSFTN GP11.phx.gbl...
Is faster that way? Any other advantages?

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Crirus,
In addition to your & the other comments about need to assign the result
back to a variable.

With four replaces in a row as you have, I would consider using
StringBuilder.R eplace instead of String.Replace.

Something like:

Imports System.Text

dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"


Dim sb As New StringBuilder(p p)
sb.Replace("{", Nothing)
sb.Replace("}", Nothing)
sb.Replace("X=" , Nothing)
sb.Replace("Y=" , Nothing)

pp = sb.ToString()

Especially if I was using string concatenation to build pp in the first
place. As I would use StringBuild.App end to build the string, then use the above Replace statements to clean it.

Dim sb As New StringBuilder(p p)

sb.Append(pt1.T oString())
sb.Append(pt2.T oString())
sb.Append(pt3.T oString())

...
sb.Replace("{", Nothing)
...

Hope this helps
Jay

"Crirus" <Cr****@datagro up.ro> wrote in message
news:ez******** *****@tk2msftng p13.phx.gbl...
dim pp as string
pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356,
Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142,
Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42,
Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"

pp.Replace("{", Nothing)
pp.Replace("}", Nothing)
pp.Replace("X=" , Nothing)
pp.Replace("Y=" , Nothing)

after this, pp is exactly the same as before??!!

Crirus



Nov 20 '05 #9
Good to see this for future needs...thanks

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in message
news:eW******** ******@tk2msftn gp13.phx.gbl...
Crirus,
It really depends on how you are building the string.

For four simple replacements. I would expect it to be a wash (the same
time).

However if you have a series of string concatenations before the
replacements, then yes I would expect the StringBuilder to be faster.

The other major advantage, each time you call string.Replace you are
creating a new temporary string object, if you do 4 replacements you will
have 4 temporary string objects.

With the StringBuilder you will have 1 temporary stringbuilder object, so
you are saving 3 objects that the GC needs to worry about. Would I worry
about just the 3 objects, probably not. However if I decided I needed 10
replacements or 20 replacements I think you will find that the StringBuilder quickly becomes the better deal...

Hope this helps
Jay

"Crirus" <Cr****@datagro up.ro> wrote in message
news:eZ******** ******@TK2MSFTN GP11.phx.gbl...
Is faster that way? Any other advantages?

"Jay B. Harlow [MVP - Outlook]" <Ja********@ema il.msn.com> wrote in

message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Crirus,
In addition to your & the other comments about need to assign the result back to a variable.

With four replaces in a row as you have, I would consider using
StringBuilder.R eplace instead of String.Replace.

Something like:

Imports System.Text
> dim pp as string
> pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
> Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
> Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356, > Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142, > Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
> Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42, > Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"

Dim sb As New StringBuilder(p p)
sb.Replace("{", Nothing)
sb.Replace("}", Nothing)
sb.Replace("X=" , Nothing)
sb.Replace("Y=" , Nothing)

pp = sb.ToString()

Especially if I was using string concatenation to build pp in the first place. As I would use StringBuild.App end to build the string, then use the above Replace statements to clean it.

Dim sb As New StringBuilder(p p)

sb.Append(pt1.T oString())
sb.Append(pt2.T oString())
sb.Append(pt3.T oString())

...
sb.Replace("{", Nothing)
...

Hope this helps
Jay

"Crirus" <Cr****@datagro up.ro> wrote in message
news:ez******** *****@tk2msftng p13.phx.gbl...
> dim pp as string
> pp="{X=356, Y=256}{X=356, Y=311.2285}{X=3 11.2285, Y=356}{X=256,
> Y=356}{X=200.77 15, Y=356}{X=156, Y=311.2285}{X=1 56, Y=256}{X=156,
> Y=200.7715}{X=2 00.7715, Y=156}{X=256, Y=156}{X=311.22 85, Y=156}{X=356, > Y=200.7715}{X=3 56, Y=256}{X=200, Y=150}{X=200, Y=177.6142}{X=1 77.6142, > Y=200}{X=150, Y=200}{X=122.38 58, Y=200}{X=100, Y=177.6142}{X=1 00,
> Y=150}{X=100, Y=122.3858}{X=1 22.3858, Y=100}{X=150, Y=100}{X=177.61 42, > Y=100}{X=200, Y=122.3858}{X=2 00, Y=150}"
>
> pp.Replace("{", Nothing)
> pp.Replace("}", Nothing)
> pp.Replace("X=" , Nothing)
> pp.Replace("Y=" , Nothing)
>
> after this, pp is exactly the same as before??!!
>
> Crirus
>
>
>



Nov 20 '05 #10

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

Similar topics

4
2677
by: Qwiati | last post by:
Hi My user has put ' with editable place and then press enter so this same way put text information with ' string into database. When I try tu user command : UPDATE and try to change text with ' and use command WHERE = ('text'') then I just received error command from SQL2000 server - I know what kind of problem is but i need your hel to get...
1
16331
by: Thomas | last post by:
It looks like the String.replace doesn't work in IE6.1. Anyone else has the same problem. I am using newest service package of IE and Win2K. Thanks
12
1826
by: Hp | last post by:
Hi All, Thanks a lot for all your replies. My requirement is as follows: I need to read a text file, eliminate certain special characters(like ! , - = + ), and then convert it to lower case and then remove certain stopwords(like and, a, an, by, the etc) which is there in another txt file. Then, i need to run it thru a stemmer(a program...
5
2007
by: Jay S | last post by:
Hi, Can't figure out the following: <concept> I want to match a specified string followed by any string that is *not* a different specified string. </concept> <specific example>
32
14783
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
2
2247
by: Joebloggs | last post by:
Hi I am trying to do an ldap lookup. I can pick up the domain name in the standard format DOMAIN\USERNAME. The problem is the company I work for expects the query in the format DOMAIN:USERNAME. I tried to do a simple string replace to replace \ to : but it turns out the only string you can't replace in c# is \ as it gives the error...
2
1354
by: Lester | last post by:
I need a regexp function which makes a match when the string contains <img...AND the img tag above dows NOT contain a certain path Here is what I have: <img\s.*(src).+> This matches if my string contains "<img .....src.....>" (the dots can be anything, I dont care). However, after the "src" part and before the
3
2062
by: Peted | last post by:
Is it possible to concatanate a string and a byte array, into a "string" variable, send it as a string to an ip socket device and have the bytes, seen as a sequence of bytes, not char or string ? I have a machine connected to a ip signal routing device. The ip routing only takes strings as data, but the machine connected, needs a sequence...
3
20581
by: DotNetNewbie | last post by:
Hi, I want to parse a string, ONLY allowing alphanumeric characters and also the underscore '_' and dash '-' characters. Anything else in the string should be removed. I think my regex is looking like: ^()*$
0
7647
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...
0
7570
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7859
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. ...
0
7930
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...
0
6210
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...
0
3617
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3600
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1181
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
896
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...

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.