HezzelQuartz Posted Sunday at 02:03 AM Share Posted Sunday at 02:03 AM 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 Link to comment Share on other sites More sharing options...
Solution Nine Posted Sunday at 02:20 AM Solution Share Posted Sunday at 02:20 AM (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 Sunday at 02:39 AM 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HezzelQuartz Posted Sunday at 05:36 AM Author Share Posted Sunday at 05:36 AM (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 Sunday at 05:43 AM by HezzelQuartz Link to comment Share on other sites More sharing options...
Nine Posted Sunday at 01:15 PM Share Posted Sunday at 01:15 PM 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted Sunday at 06:44 PM Share Posted Sunday at 06:44 PM (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 Sunday at 06:56 PM 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." Link to comment Share on other sites More sharing options...
Nine Posted Sunday at 08:03 PM Share Posted Sunday at 08:03 PM 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) 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