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!
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.
2 additional answers
Sort by: Most helpful
-
Dave Patrick 426.1K Reputation points MVP
2020-06-15T22:52:38.507+00:00 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 ManagementDisclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.
-
Ken Tucker 5,846 Reputation points
2020-06-15T23:51:24.413+00:00 The replace method returns a new string with the changed text
Dim str = "1235".Replace("1", "*")
It is the same for regex.replace