How to extract date from text

Hi

I need to extract Date from the below text in this format dd-MM-YYYY

Exchange rate Notification No.58/2022-Cus (NT) dated 07.07.2022-reg. [Effective from 08th July, 2022]

I will assign the entire text to a string variable from that entire string i need this particular value “07.07.2022”

and that capture date should convert to this format: dd-MM-yyyy

Final Output:07-07-2022

Please help me with the solution:

Thanks in advance

Likitha

Hi,

Does 07.07.2022 mean dd.MM.yyyy?
If so, the following expression will work.

DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(yourString,"\d{2}\.\d{2}\.\d{4}").Value,"dd.MM.yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")

Regards,