I want to select the latter date from a range of dates. For example, “05/11/2019-02/12/2020”- I want to select only 02/12/2020 and discard the previous date “05/11/2019-”
the string split approach
YourStringVar.Split("-"c).last()
a regex approach:
System.Text.RegularExpressions.Regex.Match(YourStringVar,"(?<=\-)[\d\/]+$").Value
Is there a C# alternative for this and above? I tried using the following for C#:
For first one: YourStringVar.Split(‘-’).last()
For second : System.Text.RegularExpressions.Regex.Match(YourStringVar, @“(?<=-)[\d/]+$”).Value()
C#:
YourStringVar.Split('-').Last();
For second : System.Text.RegularExpressions.Regex.Match(YourStringVar, @"(?<=-)[\d/]+$").Value;
Kindly note the closing ; and that C# is case sensitive
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.