is it OK to get regex result of pattern which has duplicate reference names
like
StrDatePattern As String
="\b(((?<year>\d{4})-(?<month>\d{1,2})-(?<day>\d{2}))|{(?<month>\d{1,2})
(?<day>\d{2}), (?<year>\d{4})))"?
my code segment
StrDatePattern As String
="\b(((?<year>\d{4})-(?<month>\d{1,2})-(?<day>\d{2}))|{(?<month>\d{1,2})
(?<day>\d{2}), (?<year>\d{4})))"?
Dim strDate As String = "", _
strYMD As String = ""
Dim r as regex = New Regex(StrDatePattern , RegexOptions.IgnoreCase)
Dim m as match = r.Match(myStringHoldingDateInfo)
If m.Success Then
al_posn = m.Index + 1
strDate = Mid(StringIn, al_posn, m.Length) ' works so far
strYMD = m.Result("${year)-${month}-{$day}") ' at best, I
get the year component only
Else
al_posn = 0
strDate = ""
strYMD = ""
End If
I did not have much luck using match.result to re-arrange the extracted date
string. However I was able to extract the matched date string.
I even try with another match on strYMD and then use that result to
re-arrange
the date string and still no luck.
What did I go wrong?
thank you for your time.