#cs ---------------------------------------------------------------------------- Marcus Fernström, copyright 2014 AutoIt Live Regex Version 0.1 #ce ---------------------------------------------------------------------------- #include #include #include #include #include #Region ### START Koda GUI section ### ; Koda base GUI with a few tweaks to positions. $Form1 = GUICreate("AutoIt Live Regex", 615, 438, 554, 204) $regIn = GUICtrlCreateInput("", 10, 30, 511, 21) $Label1 = GUICtrlCreateLabel("Regex", 20, 10, 35, 17) $textToCheck = GUICtrlCreateEdit("", 10, 80, 405, 339) $matches = GUICtrlCreateEdit("", 430, 80, 175, 339) $Label2 = GUICtrlCreateLabel("Text", 20, 60, 25, 17) $Label3 = GUICtrlCreateLabel("Matches", 440, 60, 45, 17) $Label4 = GUICtrlCreateLabel("Ver. 0.1", 570, 5, 51, 17) $clpButton = GUICtrlCreateButton("Clipboard", 530, 28, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $tempText = '' ; Setting up a few variables Global $resultHolder = '' Global $regToRun = '' Global $lastCheck = '' While 1 ; Main loop $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $clpButton ClipPut($regToRun) ; Copy the regex to your clipboard EndSwitch $regToRun = GUICtrlRead($regIn) ; Grab the regex to run $tempText = GUICtrlRead($textToCheck) ; The text to match against $resultHolder = StringRegExp( $tempText, $regToRun, 3) ; The result of running the regex GUICtrlSetData($matches, '') ; Clear the Matches textbox If ($lastCheck <> $resultHolder) AND (StringLen($regToRun) > 0 ) AND IsArray($resultHolder) Then ; Check if we need to run and display the checks, no point in running otherwise $iMax = UBound($resultHolder) ; Get array size For $i = 0 to $iMax - 1; ; Your average for loop _GUICtrlEdit_AppendText ( $matches, $i + 1 & ': ' &$resultHolder[$i] & @CRLF) ; Step through the array and append the results to the matches textbox Next $lastCheck = $resultHolder ; Setting lastCheck to resultHolder EndIf Sleep(100) ; Glorious sleep at last WEnd