HezzelQuartz Posted December 1, 2024 Posted December 1, 2024 If I have a textfile: Comparing files D:\DOCUMENTS\LEARN\EXAMPLE1 and D:\DOCUMENTS\LEARN\EXAMPLE2 00000010: 5B 5D 00000014: 28 B8 00000E40: B8 C0 00001159: C0 80 0000115A: 39 28 00001168: 90 20 00001169: 84 5E 0000116A: 39 28 00002878: 1C 0C 0000287B: 80 00 FC: D:\DOCUMENTS\LEARN\EXAMPLE1 longer than D:\DOCUMENTS\LEARN\EXAMPLE2 Then, I want to do StringRegExpReplace so that it become: 00000010: 5B 5D 00000014: 28 B8 00000E40: B8 C0 00001159: C0 80 0000115A: 39 28 00001168: 90 20 00001169: 84 5E 0000116A: 39 28 00002878: 1C 0C 0000287B: 80 00 How to do it? I tried in https://regex101.com/ but I still confused
Solution Nine Posted December 1, 2024 Solution Posted December 1, 2024 (edited) If all the lines you want to keep start with a 0 : $sText = StringRegExpReplace(FileRead("1.txt"), "(?m)^[^0].*\v*", "") But you may want to use this instead : Local $aList = StringRegExp($sResult, "(?m)^([0-9A-F]{8}): ([0-9A-F]{2}) ([0-9A-F]{2})$", 3) where $sResult is the output of fc.exe Edited December 1, 2024 by Nine “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
HezzelQuartz Posted December 1, 2024 Author Posted December 1, 2024 (edited) @Nine Sorry for unimportant question When I do your first answer to this file below the resulting file will have two empty line in the end (two last line will be empty) Did I do something wrong? Is there any way I can also remove that two empty line in a single "StringRegExpReplace" ======================================================================================================== Sorry, I am trying and learning both of your answer Thank You FC Example.txt Edited December 1, 2024 by HezzelQuartz
Nine Posted December 1, 2024 Posted December 1, 2024 I don't have empty lines at the end using your file : $sText = StringRegExpReplace(FileRead("FC Example.txt"), "(?m)^[^0].*\v*", "") ConsoleWrite($sText) “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Musashi Posted December 1, 2024 Posted December 1, 2024 (edited) 13 hours ago, HezzelQuartz said: the resulting file will have two empty line in the end (two last line will be empty) (Aside : my console output is identical to @Nine 's.) However, as soon as you write the output to a file, there is one (not two as in your case) blank line. This is comprehensible, as the last line does fulfill the RegEx pattern and is therefore replaced by “”. I would prefer the array variant (as already suggested by Nine) - this provides more flexible access to the individual elements. Edited December 1, 2024 by Musashi insert picture "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Nine Posted December 1, 2024 Posted December 1, 2024 As @Musashi said, there is not blank line at the end beside the fact that the last line : 0000287B: 80 00 Is also finished by @CRLF like all the others before. If you don't want it just use StringStripWS and remove those trailing characters. “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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