, , Match, . "id", :
Dim contents = Regex.Replace(contents, "\|(?'id'\d+)\r\n",
Function(m As Match)
Return m.ReplaceGroupValue("id", "[REPLACEMENT VALUE]")
End Function)
:
<Extension()> _
Function ReplaceGroupValue(ByVal m As Match, ByVal sGroupName$, ByVal sNewValue$) As String
'get the value of the specified group
Dim value = m.Groups(sGroupName).Value
Return m.Value.Replace(value, sNewValue)
End Function
, , :
Dim contents = Regex.Replace(contents, "\|(?'id'\d+)\r\n",
Function(m As Match)
Return m.ReplaceGroupValue("id", Function(id) [do something with the id])
End Function)
<Extension()> _
Function ReplaceGroupValue(ByVal m As Match, ByVal sGroupName$, ByVal callback As Func(Of String, String)) As String
'get the value of the specified group
Dim value = m.Groups(sGroupName).Value
Return m.Value.Replace(value, callback(value))
End Function
ReplaceGroupValue , , .