question

njsokalski avatar image
0 Votes"
njsokalski asked njsokalski answered

Replacing * in a VB.NET String

I'm not sure if this is the right place to ask this, but here is my question. I have a String in VB.NET which may contain the String "1*", and I would like to replace this with "*". I have tried using the Replace method of String, as well as the Replace & Escape methods of RegEx, but none of them seem to work. Neither of the following seemed to work:

.Replace("1*", "*")

.Replace("1*", "*")

And I tried several different combinations of the RegEx methods, but still no success. What should I be doing? Thanks.

not-supported
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

njsokalski avatar image
0 Votes"
njsokalski answered

I found the problem, and it was not really a problem at all, just one of those stupid mistakes that we sometimes make. I was using the wrong variable in my code, and therefore I was looking for the wrong answer! Embarrasing to admit, so if you were trying to find what was wrong, don't bother, because nothing was wrong (well, nothing that applies to this post)! But thank you to all that tried to help me!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered

They're actively answering VB.Net question in dedicated forums here.


https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral


--please don't forget to Accept as answer if the reply is helpful--


Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management


Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

vb2ae avatar image
0 Votes"
vb2ae answered

The replace method returns a new string with the changed text


             Dim str = "1235".Replace("1", "*")


It is the same for regex.replace

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.