Jump to content

RegExpQuickTester 2.5p


pixelsearch
 Share

Recommended Posts

Revisions in RegExpQuickTester (sorted by descending order)
=========

25 mar 2023 : save & reload 5 Edit Tabs content with UTF-8 (to take care of Unicode characters)
Context menu reworked with new items added, also context menu is now prepared in a separate function _PrepareContextMenu()
Newlines (@CRLF and/or @LF and/or @CR) correctly parsed & copied in clipboard, e.g. Code button (for pasting directly in Scite)
Ready : generated code > 4095 characters split in lines length acceptable by Scite, e.g < 4096 char)
Display 'next offset' (e.g. @extended) for RegEx mode 1 & 2 when successful
Changed version from "2.5j" to "2.5p"

21 feb 2023 : added a Personal Tab, where we can place stuff we want to keep as long as we wish (backup patterns etc...)
Note: the content of this Tab will not be cleared by the button "Clear" (great !) which will clear all the rest.
This Tab is a sort of personal backup saved between sessions in the ini file. Its content will never interfere with StringRegExp Results.
Changed version from "2.5i" to "2.5j"

20 feb 2023 : added a button to generate AutoIt code in ClipBoard (StringRegExp or StringRegExpReplace). Thanks ioa747 for the suggestion.
Ini file contains again binary strings (in case @crlf are found) because IniWrite doesn't accept multi-line values.
The GUI could be enlarged or maximized, not shrinked (since version 2.5g) but let's accept to shrink it a bit vertically too
Checked exact include files needed (no more, no less)
Changed version from "2.5h" to "2.5i"

14 feb 2023 : minor revision, e.g. no need of 2 include files GuiTab.au3 and GuiEdit.au3, because :
_GUICtrlTab_GetCurSel() is no more used in code since version 2.5g (included)
GUICtrlSendMsg($ebTest, $EM_LIMITTEXT, -1, 0) does the job, instead of _GUICtrlEdit_SetLimitText($ebTest, -1) which used $EM_SETLIMITTEXT
msdn : "the EM_SETLIMITTEXT message is identical to the EM_LIMITTEXT message"
Changed version from "2.5g" to "2.5h"

12 feb 2023 : added GUI style $WS_SIZEBOX
Registered WM_GETMINMAXINFO to prevent shrinking the GUI (it can be enlarged or maximized, not shrinked)
Changed the resizing method of the Tab Control to $GUI_DOCKAUTO (thanks Nine & mistersquirrle for resizing help)
Deleted the (now) useless code from version 2.5f which allowed to perform an...
...accurate checking of right-click coords inside the edit box of the Search Pattern Tab to display the context menu (when GUI is maximized).
Changed version from "2.5f" to "2.5g"

10 jan 2023 : Added $bTab_3IsHighlited to highlight Tab 3 ("ResultSuffix") when "its" edit control $ebResultSuffix contains something.
This Tab 3 ("ResultSuffix") may be not as useful as Tab 2 ("ResultPrefix") which was added on 25 dec 2022, but who knows ?
Accurate checking of right-click coords inside the edit box of the Search Pattern Tab to display the context menu (when GUI is maximized)
Changed version from "2.5e" to "2.5f"

6 jan 2023 : the annoying @CRLF at the end of the Result edit control has been removed (it's safer to see the very exact content,
especially when there are spaces at the end of the result, no need of a disturbing superfluous @CRLF)
Changed version from "2.5d" to "2.5e"

28 dec 2022 : no more Binary in .ini file (mikell's suggestion)
"Replace Pattern" reminder: to replace all matches with an empty string, just indicate a non existing match group, ex. $99
++++++++++++++++++++++++++
Changed version from "2.5c" to "2.5d"

25 dec 2022 : in main loop, no need to call RegExpExecute() if $nMsg = -11 ($GUI_EVENT_MOUSEMOVE = -11)
Added $bTab_1IsHighlited to highlight Tab 1 ("Replace Pattern") when "its" edit control $ebRegExpReplace contains something.
Added $bTab_2IsHighlited to highlight Tab 2 ("ResultPrefix") when "its" edit control $ebResultPrefix contains something.
Save content of new edit control "Result Prefix" as Binary into ini file (see note dated 29 nov 2018 above)
Cosmetic changes (for example added the useful $TCS_FOCUSONBUTTONDOWN style)
Changed version from "2.5b" to "2.5c"

2 feb 2021 : Changed GUICtrlSendMsg($ebRegExp, 0x00C2, 0, ...)
to GUICtrlSendMsg($ebRegExp, 0x00C2, 1, ...) ; 0x00C2 = $EM_REPLACESEL  ,  1 (or True) = allow Undo (MSDN)

2 jun 2020 : Added in the script "  -  Result length: " & StringLen($sResult)

19 jun 2019 : Added "positive lookbehind" and "negative lookbehind" to context menu.
Added \R to context menu, i.e any newline sequence (@CRLF, @CR, @LF)

20 feb 2019 : deleted dozens of variables names during context menu creation, see notes below, just before creating the context menu
Added "positive lookahead" and "negative lookahead" to context menu.

26 dec 2018 : replaced GUICtrlSendMsg($ebTest, $EM_LIMITTEXT, -1, 0) from 5 nov 2018, with _GUICtrlEdit_SetLimitText($ebTest, -1)

13 dec 2018 : added variable $hDummycontext used for function _TrackPopupMenu() : no need to redefine it at each right click, once is ok
delete 3 handles used in Func WM_COMMAND() : control id's do the same job

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()

1 dec 2018 : if GUI is maximized, then right click behavior (to display context help menu) is a bit different in Search Pattern Tab
As coordinates of Search Pattern Tab has "changed" when GUI is maximized, we will display help context menu in more cases :
look at the $WIN_STATE_MAXIMIZED part in script.

30 nov 2018 : changed trigger mouse button for context menu for regexp's help syntax : from "04" (middle button) to "02" right button.
Note : Lazycat's Func _IsPressed($nKey) is no more needed because $aInfo[3] = 1 does the same job for testing right click !
So now if you want to copy the regexp part, it wont work with right click. Select it with mouse, then ctrl-c : ok !

29 nov 2018 : write "match text" edit control content in a separate txt file in plain text (too big now for ini file), not in binary.
Binary stays in ini file (for Pattern and Replace) to take care of silly CR in Pattern or Replace edit controls

28 nov 2018 : drag & drop a txt file's content into Edit control, seems to work !

27 nov 2018 : changed Dummy label control to 1 pixel size ! (used for right click context help menu)

13 nov 2018 : changed Lazycat's 2 Checkbox by 2 Button (wondering why he choosed Checkbox instead of Button)
Added $ES_READONLY to Result Editbox (so had to add $WS_HSCROLL too, to stay compatible with Lazycat's special output in this Editbox)
Because of $ES_READONLY, had to add $WS_TABSTOP too (more enjoyable when tabbing)

10 nov 2018 : Delete the function _EditReplaceSel() , keeping only 1 line of it in main script !
After that change, insertion (copied from context menu) can be done at 1st position

07 nov 2018 : changed fonts in several places (not very important)
moved Gui code lines to allow using Tab correctly between fields

05 nov 2018 : added line GUICtrlSendMsg($ebTest, $EM_LIMITTEXT, -1, 0)
it allows to paste a text to check > 30.000 characters (native limit of Edit control)
msdn "If cchMax is set to -1, the multiline edit control limit is 0x7FFFFFFE" i.e 2.147.483.646 characters !
https://www.autoitscript.com/forum/topic/187377-guictrlcreateedit/
https://msdn.microsoft.com/en-us/library/ms908364.aspx
 

Edited by pixelsearch
Update to version 2.5p
Link to comment
Share on other sites

Link to comment
Share on other sites

I realized @ptrex, you ask @pixelsearch for tips, but I want to share my experience on getting more familiar with RegEx:
I used interactive tutorials in the past like this one for example (which works pretty well for me).
Maybe this also fits your personal learning type?!

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

  • pixelsearch changed the title to RegExpQuickTester 2.5h
10 hours ago, ptrex said:

Do you have any good tips to get this to a descent level to understand the syntax properly ...

Hi @ptrex
I got a book named "Regular Expressions - The Complete Tutorial" by Jan Goyvaerts. You can easily find it on the web (it's a pdf file, 921Kb) . I consult it from time to time, but not as often as I should.

The script above has been revised today from version 2.5g to 2.5h, it's just a minor revision.

Link to comment
Share on other sites

230215-044227-602_AutoIt3_fWkeI.png.693b100a11b230948a7b2e79c140c698.png230215-044227-602_AutoIt3_fWkeI.png.e5a178c50d9d2684020f07666f205705.png

@pixelsearch  :dance:

Well done, your tool is very good, especially (and not only) for beginners.

With the guide on the right click, it guides you briefly, and explains what the symbols do.

Congratulations !

 

 

 

 

if i could suggest,

since I see that there is a position available on the right of the tabs. :)

or a hole between the buttons :)

to give the complete code, for copying

in the form (ready for delivery)

#include <Debug.au3>
Local $sRegex = '"data":"([^"]+)"'
Local $sString = '[[{"records":{"data":"random data"}}],[{"filtered":{"data":"unknown variable"}}],[{"duplicate":{"data":"not constant"}}],{"subject":"Test"}]'

Local $aArray = StringRegExp($sString, $sRegex, 3)
_DebugArrayDisplay($aArray)

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

4 hours ago, ioa747 said:

if i could suggest [...] to give the complete code, for copying in the form (ready for delivery)

Thanks for the idea (and your encouragements) :)
A button to generate the whole code would be nice (copying it to ClipBoard)

We'll have to think about what to do if the "Replace Pattern" Tab is filled (and then maybe the "Replace count" field too). In this case, a StringRegExpReplace() function should be generated and not a StringRegExp() and its _ArrayDisplay() function etc...

I'll think of it when I got some free time (this week being busy)
 

Link to comment
Share on other sites

  • pixelsearch changed the title to RegExpQuickTester 2.5i

@ioa747 Following your suggestion, I added a couple of functions to generate the AutoIt code, it seems to work fine. 2 cases may appear when you click on the "Code" button :

1) StringRegExp code :

72106233_CodeStringRegExp.png.26eb4c30b5c795901f2bd09a60a20141.png

2) StringRegExpReplace code. In this example the 'Replace Pattern' Tab contains  $2.$1.$3  (surrounded with 1 space)

2018371102_CodeStringRegExpReplace.png.59547fe32e0b5a8b23e758f21b900307.png

In both pics above, the GUI is vertically shrinked (on purpose) just to reduce the uploaded pics size on the Forum (the regular vertical size is the one found in the pic in 1st post).

This new version is named "RegExpQuickTester 2.5i.au3" and its listing is found in 1st post.

Link to comment
Share on other sites

On 2/15/2023 at 9:32 PM, ioa747 said:

I see that there is a position available on the right of the tabs.

Well... maybe we can fill it with a Personal Tab.
In this Tab, we can place stuff we want to keep as long as we wish (alternative patterns etc...) it's a sort of personal backup saved between sessions in the ini file. This Tab content will never interfere with StringRegExp Results.

1110454867_PersonalTab(ontest).png.9c1b2093b51f20947cf47dee95f72345.png

If you guys think it's interesting, then I'll add it in the code.
Have a great day :)

Link to comment
Share on other sites

something like favorite patterns

I like it !  👍

 

PS

I have found three link  that I think are worth sharing with all off you

https://regex101.com/

https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285

https://medium.com/factory-mind/regex-cookbook-most-wanted-regex-aa721558c3c1

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

  • pixelsearch changed the title to RegExpQuickTester 2.5j
9 hours ago, Sascha said:

I immediately loved it

I understand this, as I had the very same feeling when discovering this wonderful piece of software back in 2018. Lazycat, w0uter and @steve8tchreally did a great job at the time.

Just a minor change I just made, inside the main While...WEnd loop :

GUICtrlSetState($ebRegExp, $GUI_FOCUS)

commented out, changed to :

; GUICtrlSetState($ebRegExp, $GUI_FOCUS) ; better caret position when line commented out.

If someone uses the special context menu to paste anything from the menu, then the caret will be placed just after what has been pasted (when the line is commented out), I like this behavior.

On the contrary, when the line is uncommented, then the caret will be placed at the end of the pattern after the paste process has ended (though I saw the caret also placed anywhere in the pattern too, when the line is uncommented)

Anyway no big deal, it's just a minor cosmetic change. Uncommented line or commented out, to each his own :)

Edited by pixelsearch
Link to comment
Share on other sites

  • 3 weeks later...

Hi pixelsearch

Since I very rarely use regular expressions, I am too lazy to learn this topic. 🙂
But looking at such wonderful programs as this, I always dreamed of a lazy version.
This is when I could enter "match text" and "result", and get "pattern".

Is it possible?

Link to comment
Share on other sites

  • pixelsearch changed the title to RegExpQuickTester 2.5p

Updated to version 2.5p (script found in 1st post) . Revisions are :

25 mar 2023 : save & reload 5 Edit Tabs content with UTF-8 (to take care of Unicode characters)
Context menu reworked with new items added, also context menu is now prepared in a separate function _PrepareContextMenu()
Newlines (@CRLF and/or @LF and/or @CR) correctly parsed & copied in clipboard, e.g. Code button (for pasting directly in Scite)
Ready : generated code > 4095 characters split in lines length acceptable by Scite, e.g < 4096 char)
Display 'next offset' (e.g. @extended) for RegEx mode 1 & 2 when successful
Changed version from "2.5j" to "2.5p"

Thanks to @mikell for his advices while I was modifying the context menu :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...