Text file: change date format

Hi,
i have a txt file with date in this format “26.04.2021”.
I need to change format to “26/04/2021”
It’s possible use Replace function with regular expression?

Thanks

Hi @d_liberati

String.Replace(“.”,"") will give the expected output.

Regards

In the file i have other data, so i can’t replace “.” with “,”, but i need to use a regular expression to search date.

Hi @d_liberati

How about using below regex?

Regards

Hi @d_liberati

Try this

System.Text.RegularExpressions.Regex.Replace("20.12.2021", "(\d{2})\.(\d{2})\.(\d{4})", "$1/$2/$3")

for whole text use

System.Text.RegularExpressions.Regex.Replace(fullTextString, "(\d{2})\.(\d{2})\.(\d{4})", "$1/$2/$3")
1 Like

This worked for me too

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.