Ghost1982 Posted March 4, 2020 Share Posted March 4, 2020 (edited) Hello I'm obtaining date/time string into variable using _NowCalc(). String format is YYYY/MM/DD HH:MM:SS I'd like to replace all the "/", "<space>" and ":" with "<nothing>". How should I "show it" to StringRegExpReplace? I was trying to separate characters by brackets (like in Help) but it doesn't work $localTime = StringRegExpReplace($localTime, "[/][ ][:]", "") Edited March 4, 2020 by Ghost1982 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 4, 2020 Share Posted March 4, 2020 (edited) @Ghost1982 Use only one character class, as in the example below: #include <StringConstants.au3> ConsoleWrite(_RemoveDateTimeSeparators('YYYY/MM/DD HH:MM:SS') & @CRLF) Func _RemoveDateTimeSeparators($strString) Return StringRegExpReplace($strString, '[ :/]', '') EndFunc By the way, if you want to be even verbose, you should use a different pattern: #include <StringConstants.au3> ConsoleWrite(_RemoveDateTimeSeparators('2020/03/04 12:10:59') & @CRLF) Func _RemoveDateTimeSeparators($strString) Return StringRegExpReplace($strString, '(\d{4})/(\d{2})/(\d{2}) (\d{2}):(\d{2}):(\d{2})', '$1$2$3$4$5$6') EndFunc Edited March 4, 2020 by FrancescoDiMuro mikell 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Ghost1982 Posted March 4, 2020 Author Share Posted March 4, 2020 That's something new "ConsoleWrite". In which cases should I use this function? Is it somethin like "put to clipboard"? Link to comment Share on other sites More sharing options...
Nine Posted March 4, 2020 Share Posted March 4, 2020 (edited) It is mainly a debugging tool that easily enables you to show results of operation when you run your script from Scite editor. Although you can compile your script non-GUI (CUI) and use ConsoleWrite to send information to DOS console, it is rarely used in that perspective. Also you can use ConsoleWrite in Parent-Child processes where child process is sending through stream information to parent process. This is a more frequent usage of the function. Edited March 4, 2020 by Nine Ghost1982 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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