MarcusFernstrom Posted November 18, 2014 Share Posted November 18, 2014 I figured I'd have a go at creating a live regex tester, not a big deal right? Input box for regex, textfield with text to test against, and an output box showing results. But here's where it gets weird. If I run: $resultHolder = StringRegExp( "Edit 1", "Edit", 0) I get 1, there's a match. But if I do: $resultHolder = StringRegExp( "Edit 1", $tempText, 0) Where tempText is Edit, I get 0, no matches.. I can't figure it out. Anyone run into something similar? My *guess* is that there are extra characters ending up in the variable somehow, which throws off the regex match- Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 18, 2014 Moderators Share Posted November 18, 2014 No reproducer script? Without one, you force us to write one, then guess how you are doing things. This would be as much work as I'd be willing to put into debugging for you with what you've provided, but it works: Global $gs_testVar = "Edit" Global $gb_retVal = StringRegExp("Edit 1", $gs_testVar) ConsoleWrite($gb_retVal & @CRLF) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
MarcusFernstrom Posted November 18, 2014 Author Share Posted November 18, 2014 (edited) Allright, let's see if this works.. -edit- reading this over, I found my misteak, I flipped the StringRegExp... expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 260, 180) $regIn = GUICtrlCreateInput("Input1", 10, 30, 591, 21) $textToCheck = GUICtrlCreateEdit("", 10, 80, 265, 349) GUICtrlSetData(-1, "Edit1") $matches = GUICtrlCreateEdit("", 290, 80, 315, 169) GUICtrlSetData(-1, "Edit2") $Label1 = GUICtrlCreateLabel("Regex", 20, 10, 35, 17) $Label2 = GUICtrlCreateLabel("Text", 20, 60, 25, 17) $Label3 = GUICtrlCreateLabel("Matches", 300, 60, 45, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $tempText = '' Global $resultHolder = '' Global $regToRun = '' While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $regToRun = GUICtrlRead($regIn) $tempText = GUICtrlRead($textToCheck) $resultHolder = StringRegExp( "Edit 1", $tempText, 0) GUICtrlSetData( $matches, $resultHolder & ' - ' & _NowTime()) Sleep(100) WEnd Edited November 18, 2014 by MarcusFernstrom Link to comment Share on other sites More sharing options...
jguinch Posted November 18, 2014 Share Posted November 18, 2014 $resultHolder = StringRegExp( $tempText, $regToRun, 0) GUICtrlSetData( $matches, $resultHolder & ' - ' & _NowTime()) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Bert Posted November 18, 2014 Share Posted November 18, 2014 (edited) @ MarcusFernstrom: have you looked at the Regex script in the help file? Look for "Tutorial - Regular Expression" and at the bottom of the page there is a button (open StringRegExpGUI.au3) to open the Regex script in SciTE. Edited November 18, 2014 by Bert The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
MarcusFernstrom Posted November 18, 2014 Author Share Posted November 18, 2014 Yes I found my error the other night (As reflected in the edit, last night) I had simply flipped the regex and string in StringRegExp. I actually finished up version 0.1 of this and put up in Example Scripts 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