taurus905 Posted October 30 Share Posted October 30 Hello @pixelsearch I hope you're doing well. Would this be a useful change to your script for displaying an Array of Arrays? expandcollapse popupFunc _GenerateCode() Local $sClipTxt, $sSubject, $sPattern $sSubject = _TextSplit(GUICtrlRead($ebTest), "$sSubject") ; Prepare subject text $sPattern = _TextSplit(GUICtrlRead($ebRegExp), "$sPattern") ; Prepare search pattern ; Check if the subject or pattern is empty If $sSubject = "" Or $sPattern = "" Then MsgBox(0, "Generating code", "Error: Match Text or Search Pattern is empty", 0, $hGUI) Return EndIf ; Generate code for handling array of arrays (Mode 4) If $nMode = 4 Then $sClipTxt = "#include <Array.au3>" & @CRLF & @CRLF & _ "Local $sSubject, $sPattern, $aArray" & @CRLF & @CRLF & _ "$sSubject = " & $sSubject & @CRLF & @CRLF & _ "$sPattern = " & $sPattern & @CRLF & @CRLF & _ "$aArray = StringRegExp($sSubject, $sPattern, 4)" & @CRLF & _ "If @error Then" & @CRLF & _ " MsgBox(0, 'Error', 'No matches found or invalid pattern')" & @CRLF & _ " Exit" & @CRLF & _ "EndIf" & @CRLF & @CRLF & _ "; Loop through the array of arrays" & @CRLF & _ "For $i = 0 To UBound($aArray) - 1" & @CRLF & _ " Local $aMatch = $aArray[$i]" & @CRLF & _ " ConsoleWrite('Match ' & ($i + 1) & @CRLF)" & @CRLF & _ " ConsoleWrite('Full Match: ' & $aMatch[0] & @CRLF)" & @CRLF & _ " ConsoleWrite('Group 1: ' & $aMatch[1] & @CRLF)" & @CRLF & _ " ConsoleWrite('Group 2: ' & $aMatch[2] & @CRLF & @CRLF)" & @CRLF & _ "Next" & @CRLF Else ; Generate standard code for modes other than 4 $sClipTxt = "Local $sSubject, $sPattern, $aArray" & @CRLF & @CRLF & _ "$sSubject = " & $sSubject & @CRLF & @CRLF & _ "$sPattern = " & $sPattern & @CRLF & @CRLF & _ "$aArray = StringRegExp($sSubject, $sPattern, " & $nMode & ")" & @CRLF & _ "If @error Then" & @CRLF & _ " MsgBox(0, 'Error', 'No matches found or invalid pattern')" & @CRLF & _ " Exit" & @CRLF & _ "EndIf" & @CRLF & _ "_ArrayDisplay($aArray)" EndIf ; Copy generated code to clipboard ClipPut($sClipTxt) MsgBox(0, "Code (copied to Clipboard)", ClipGet(), 0, $hGUI) EndFunc ;==>_GenerateCode Example output code: #include <Array.au3> Local $sSubject, $sPattern, $aArray $sSubject = 'name1@gmail.com, name2@yahoo.com' $sPattern = '(\w+)@(\w+\.\w+)' $aArray = StringRegExp($sSubject, $sPattern, 4) If @error Then MsgBox(0, 'Error', 'No matches found or invalid pattern') Exit EndIf ; Loop through the array of arrays For $i = 0 To UBound($aArray) - 1 Local $aMatch = $aArray[$i] ConsoleWrite('Match ' & ($i + 1) & @CRLF) ConsoleWrite('Full Match: ' & $aMatch[0] & @CRLF) ConsoleWrite('Group 1: ' & $aMatch[1] & @CRLF) ConsoleWrite('Group 2: ' & $aMatch[2] & @CRLF & @CRLF) Next Console output: Match 1 Full Match: name1@gmail.com Group 1: name1 Group 2: gmail.com Match 2 Full Match: name2@yahoo.com Group 1: name2 Group 2: yahoo.com Thank you for a great tool. taurus905 pixelsearch 1 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
pixelsearch Posted October 30 Author Share Posted October 30 (edited) @taurus905 thanks for your idea, anything would be better than these bunches of {Array[3]} rows actually displayed when RegExp Mode is 4. I'll think about it, having in mind that Nine & Gianni already got ways to display an "Array of Arrays" using their own UDF's If I ever script it, I'm not sure ConsoleWrite should be the best way to do it (imagine the script is compiled...) . My 1st thought would be to display the RegExp Mode 4 in ArrayDisplay, maybe in the same way as Mode 2, but with all Global matches & Groups following each other on separate rows (1D), or why not, each Global match and its Groups on the same row (in different columns, i.e. 2D), we'll see in time... Edited October 30 by pixelsearch taurus905 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted November 10 Author Share Posted November 10 (edited) This is the code that should be generated with the new version of the script "RegExpQuickTester 2.5r" (to be uploaded in a couple of days) The function _ViewSubArrays() is generated in case the user chooses a Regex Mode 4 (array of arrays) then he'll be able to see what's inside the internal sub-arrays. Thanks to @jchd who indicated me that the internal sub-arrays could have have a different number of rows, depending on the pattern. expandcollapse popup#include <Array.au3> Local $sSubject, $sPattern, $nMode, $aArray $sSubject = 'name1@gmail.com, name2@yahoo.com' $sPattern = '(\w+)@(\w+\.\w+)' $nMode = 4 $aArray = StringRegExp($sSubject, $sPattern, $nMode) If Not @error Then Switch $nMode Case 1 To 3 _ArrayDisplay($aArray, '_ArrayDisplay mode ' & $nMode) Case 4 _ArrayDisplay($aArray, 'Array of arrays') _ViewSubArrays($aArray) EndSwitch Else MsgBox(0, 'StringRegExp', 'error = ' & @error & (@error = 1 ? ' (no matches)' : ' (bad pattern)')) EndIf Func _ViewSubArrays(Const ByRef $aArray) Local $aArray2[Ubound($aArray)][100], $iNbCol, $iMaxCol SplashTextOn('', 'Preparing 2D array' & @crlf & 'please wait...', 250, 50, -1, -1, 1 + 32) For $i = 0 To Ubound($aArray) - 1 $iNbCol = Ubound($aArray[$i]) ; 1 internal 1D sub-array will become 1 row in a 2D array If $iNbCol > $iMaxCol Then $iMaxCol = $iNbCol $aArray2[$i][0] = ( StringLen(($aArray[$i])[0]) < 61 ) _ ; column 0 always exists (global match) ? ($aArray[$i])[0] _ : ( StringLeft(($aArray[$i])[0], 30) & ' ... ' & StringRight(($aArray[$i])[0], 30) ) For $j = 1 To $iNbCol - 1 $aArray2[$i][$j] = ($aArray[$i])[$j] Next Next Redim $aArray2[Ubound($aArray)][$iMaxCol] SplashOff() _ArrayDisplay($aArray2, 'Internal sub-arrays', Default, Default, Default, 'Global match') EndFunc ;==>_ViewSubArrays I wonder if this function _ViewSubArrays() should always be generated, no matter the Mode chosen by the user (1 to 4) . It seems there are advantages and disavandvantages to always generate it. Also, in case of Mode 4, should we _ArrayDisplay twice (like in the generated script above) or simply _ArrayDisplay once (the one inside _ViewSubArrays) Questions, always questions Edited November 11 by pixelsearch final generated code just before uploading new version 2.5r Link to comment Share on other sites More sharing options...
mLipok Posted November 10 Share Posted November 10 Did you merge my changes ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
mLipok Posted November 10 Share Posted November 10 Can we move developing to GitHub ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
pixelsearch Posted November 10 Author Share Posted November 10 (edited) On 11/10/2024 at 7:06 PM, mLipok said: Did you merge my changes ? Just a couple of ones as stated on my revision post 2 dec 2018 : trying mLipok's Func WM_COMMAND to prevent CPU overheat : don't execute RegExpExecute() constantly, only if changes in GUI (test on $nMsg) or if changes are done "live" in 3 Edit controls (test on $_g_bWasAChange = True in Func WM_COMMAND() You can see them in the code Global $_g_bWasAChange = True ; mLipok, cf Func WM_COMMAND() While 1 ... If $_g_bWasAChange Or ($nMsg <> 0 And $nMsg <> -11) Then ; mLipok for $_g_bWasAChange . $GUI_EVENT_MOUSEMOVE = -11 (me) RegExpExecute() $_g_bWasAChange = False EndIf WEnd Func WM_COMMAND(...) ... Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control (mLipok) $_g_bWasAChange = True ... EndFunc ;==>WM_COMMAND On 11/10/2024 at 7:07 PM, mLipok said: Can we move developing to GitHub ? Thanks for the suggestion, but I prefer to update the script only on AutoIt Forum. Edited November 11 by pixelsearch typo Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted November 11 Share Posted November 11 12 hours ago, pixelsearch said: Thanks for the suggestion, but I prefer to update the script only on AutoIt Forum. Fair enough @pixelsearch, but this also means you don't want to have contributors to your code except the people posting here and you will add changes, right? It's totally up to you, but this way is quite inflexible and a bit sad. Don't get me wrong, I'm just more on @mLipok side here 😅 . Apart from that, thanks for the RegEx Tester Tool 👌 . Best regards Sven Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Nine Posted November 11 Share Posted November 11 4 hours ago, SOLVE-SMART said: means you don't want to have contributors to your code except the people posting here Who will know about this tool beside those who come here ? “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...
SOLVE-SMART Posted November 11 Share Posted November 11 3 hours ago, Nine said: Who will know about this tool beside those who come here ? Thanks @Nine for the interesting question. The SEO functionality of GitHub projects is more advanced than the SEO settings (meta infos) of this forum. This could lead to a wider range in terms of "who knows about the tool". Every time I search for a specific approach to solve an AutoIt issue, I use Google, DuckDuckGo etc., instead of the forum search. In case I would search for a RegEx related tool, I would have better results if the code is hosted on GitHub. For those who are not registered in the forum, but want to contribute or even just ask for things, they have to register. Most developers are already registered on GitHub for other projects and languages - so they would not register in this forum at all for a single question (of course this is only one example). I don't want to start a fundamental discussion or simply share my personal preferences, no. I just want to express that there are valid use cases. Best regards Sven Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
pixelsearch Posted November 11 Author Share Posted November 11 Hi everybody I just uploaded the new version 2.5r (11 nov 2024) of the script, download from 1st post. Changes of 2 last versions are : 11 nov 2024 : added a function _ViewSubArrays() in the generated code: this is useful if the user checked Mode 4 which "returns an array of arrays containing global matches including the full match." In this case the function _ViewSubArrays() will display the content of all internal sub-arrays, each internal 1D sub-array becoming 1 row in a 2D array. Thanks to taurus905 for the suggestion, not forgetting jchd who indicated that the internal sub-arrays could have have a different number of rows, depending on the pattern. Changed version from "2.5q" to "2.5r" 10 feb 2024 : check length of 'Personal' Tab before exiting the script : refuse to leave if > 64KB (see notes in script, part Case $GUI_EVENT_CLOSE, $btnClose) Related : Edit Control $ebPersonal got an 'unlimited' text size to bypass the 30.000 characters by default. Changed version from "2.5p" to "2.5q" (version 2.5q wasn't uploaded on the Forum) Thanks @taurus905 for suggesting to display the internal arrays in Mode 4 A thought to @mikell (who sadly is not with us anymore) he insisted that I change this explanative line from the context menu... "\G beginning of string, then where previous match ended" To... "\G beginning of string, or end of the previous match" It's done buddy, I didn't forget SOLVE-SMART and ioa747 2 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