@brasil. If you are using the RegEx callouts. PLEASE double-check that you are getting the correct results (and that you are not getting unwanted text duplication)! Some of the special RegEx characters and modes that I tested, did not seem to be working as I expected them to.
@4GForce. Yes, callouts are a little bit hidden in the documentation! The behaviour I demonstrated, that I *didn't* want this time, could come in handy in future. When callouts do work, they are so convenient versus loops, although I've probably only been using RegEx a lot since I wrote my tutorial about a month ago, and became a big fan, using it in many more places than I used to. It's nice since I became able to decipher all the examples on this forum.
RegEx callouts helped me greatly speed up a method I used that parsed about a MB of text, which I had used a parsing loop for. Basically it counted datestamps, and checked for invalid/blank 'headers' that I put underneath datestamps, in my 1 MB temporary text file, every time I saved the file. The procedure got slower as the txt got bigger, and I had to move out the text, but after the rewrite it's still fast enough at the current txt's size.
The tutorial I wrote:
RegEx handy examples (RegExMatch, RegExReplace) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?t=28031
==================================================
Some tests:
Code: Select all
q::
vOutput := ""
RegExMatch("abcdef", "..(?CCallout)") ;ab,bc,cd,de,ef
;RegExReplace("abcdef", "..(?CCallout)") ;same result as above
MsgBox % Clipboard := vOutput
vOutput := ""
RegExMatch("abcdef", "...(?CCallout)") ;abc,bcd,cde,def
MsgBox % Clipboard := vOutput
vOutput := ""
RegExMatch("abc", ".*(?CCallout)") ;abc,ab,a,,
MsgBox % Clipboard := vOutput
vOutput := ""
RegExMatch("abc", ".{1,3}(?CCallout)") ;abc,ab,a,bc,b,c
MsgBox % Clipboard := vOutput
Return
Callout(m)
{
global vOutput
if (vOutput = "")
vOutput .= m
else
vOutput .= "," m
Return 1
}
[EDIT:] I posted a revised version of the earlier script, above.