I'm pulling out my hair over the following function:
Public Function SetVersion(ByVal hl7Message As String, ByVal newVersion As String) As String
Dim rgx = New Regex("^(?<pre>.+)(\|\d\.\d{1,2})$", RegexOptions.Multiline)
Dim m = rgx.Match(hl7Message)
Return rgx.Replace(hl7Message, "${pre}|" & newVersion, 1, 0)
End Function
For simplicity, I'm testing against the following input:
dsfdsaf|2.1
wretdfg|2.2
sdafasd3|2.3
What I need to accomplish is replace "|2.1" in the first line with another value, say "|2.4". What is happening instead is that "|2.3" is getting replaced in the last line. It's as if I hadn't specified Multi-Line mode. Moreover, the following online tool returned correct matches. So, anyone who can see a mistake in my regex or code, please point it out. Thanks.