I’m having a few problems with Regular Expressions in VB.NET.
I have a String like this one: "[Type=User][User=Hello]Thats the message"
I want to have the "Thats the message" part, so I thought that the best way to do that was replacing "[Type=User][User=Hello]" for "".
Notes:
-
"Thats the message"is always at the end of the String and it can be""(without characters). -
[Type=XXXX]can be anything, I mean, it can be[Type=Password],[Type=Message]…
So, here is what I did:
Dim regOptions As RegexOptions = RegexOptions.IgnoreCase Or RegexOptions.Singleline
Regex.Replace(buffer, "^(.*)[^\]]*$", "", regOptions)
It doesn’t work, the string ‘buffer’ is not modified.
According to the documentation of that overload it will return the resulting string (after all, in .Net strings are immutable).
So, instead, try: