I have a problem with replacing a number in a string.
The code is:
Dim Searchstring As String= "2 7 12 33 4 15 22 30 15"
Dim Pattern As String= "^([0-9]$)"
Dim Match As String = Val(TextBox1.Text)
Dim ReplacementString As String = "0"
Dim rgx As Regex = New Regex(pattern)
Dim NewString As String
NewString = Regex.Replace(Searchstring, Match, ReplacementString)
RichTextBox2.Text = NewString
The problem is that when I input a number, say "2", in the textbox and run the program, the replace will be as follows in the richtextbox2.text: 0 7 10 33 4 15 00 30 15 instead of 0 7 12 33 4 15 22 30 15
But when I input the number of "22" or "12" then only these numbers will be replaced and that is okay.
So how can I find a pattern that replaces only the number "2" if I want that and only that, and not change the "12" or "22"?
Please can you help me with this case?