下面这段代码是想把不标准的日期改成标准日期格式(YYYY-MM-DD)
Dim s As String = "2021-4就职百度公司。2021-04-26辞职"
Dim d As String = "(\d){4}(\-)(\d)?(\d)(?=[^\x00-\xff])"
Dim rgx As New System.Text.RegularExpressions.Regex(d)
Dim str As String
For Each match As System.Text.RegularExpressions.Match In rgx.Matches(s)
If match.Value.Length = 6 Then
str = match.Value.Insert(5, "0") & "-15"
ElseIf match.Value.Length > 6 Then
str = match.Value & "-15"
End If
s = s.Replace(match.Value, str)
Next
MessageBox.Show(s)
如果字符串是"2021-4就职百度公司。2021-04-26辞职",可以改写成"2021-04-15就职百度公司。2021-04-26辞职";
但如果字符串是"2021-04就职百度公司。2021-04-26辞职",就会改写成"2021-04-15就职百度公司。2021-04-15-26辞职"
请教如何处理?