funkey Posted January 7, 2020 Share Posted January 7, 2020 Hello, wisch you a happy new year! Can you help me to find a regexp pattern for replacing timestamps in a csv file please. I have this Format in the file: 21.07.2019;14:12:10 (dd.mm.yyyy;hh:mm:ss) but I Need this: 2019-07-21 00:00:00 (yyyy-mm-dd hh:mm:ss) Thanks, would be great if you can help me. P.S.: I want to use StringRegExpReplace for the hole file/string. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Marc Posted January 7, 2020 Share Posted January 7, 2020 One possible solution: $input = "21.07.2019;14:12:10" $output = StringRegExpReplace($input, "(\d\d)\.(\d\d)\.(\d\d\d\d);", "\3-\2-\1 00:00:00") ConsoleWrite($output) best regards, Marc funkey 1 Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
funkey Posted January 7, 2020 Author Share Posted January 7, 2020 (edited) Thanks a lot, works great! (without 00:00:00, because I made an error; time has to be the same) Edited January 7, 2020 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Musashi Posted January 7, 2020 Share Posted January 7, 2020 Local $sInput = "Date Line 01 = 21.07.2019;14:12:10 " & @CRLF & _ "Date Line 02 = 29.03.2014;03:04:59 " & @CRLF & _ "Date Line 03 = 03.12.2013;22:41:15 " Local $sOutput = StringRegExpReplace($sInput, "(\d{2})\.(\d{2})\.(\d{4});(\d{2}):(\d{2}):(\d{2})", "\3-\2-\1 \4:\5:\6") ConsoleWrite($sInput & @CRLF & @CRLF) ConsoleWrite($sOutput & @CRLF) pixelsearch and funkey 1 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now