Problem with RegExMatch...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
CodeMonkey
Posts: 29
Joined: 10 Feb 2016, 12:11

Problem with RegExMatch...

03 Jun 2016, 06:13

I'm trying to identify if a window title contains a specific pattern but my code doesn't work. Could someone help?

Code: Select all

WinGetActiveTitle, title
	FoundPos := RegExMatch(%title%, "\K\d{2,}-\d{2,}-\d{2,}(?=\s)")
	If (FoundPos = 1)
	{
		<Rest of program>
		
	}
The pattern my code is looking for is: "ab-cd-xy"

For instance: "Example window 12-34-56 blah blah" should return FoundPos =1

My code doesn't work, I'm doing something wrong... Could someone help?
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Problem with RegExMatch...

03 Jun 2016, 07:54

RegExMatch is a function which uses expression syntax and you used %'s around the variable named title.

HTH
CodeMonkey
Posts: 29
Joined: 10 Feb 2016, 12:11

Re: Problem with RegExMatch...

03 Jun 2016, 11:01

I don't understand what you mean...?
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Problem with RegExMatch...

03 Jun 2016, 11:42

Code: Select all

WinGetActiveTitle, title
	FoundPos := RegExMatch(title, "\K\d{2,}-\d{2,}-\d{2,}(?=\s)")
	If (FoundPos = 1)
	{
		<Rest of program>
 
	}
Do you see it now?
AllUrBaseRBelong2Us
Posts: 35
Joined: 09 Nov 2015, 11:15

Re: Problem with RegExMatch...

04 Jun 2016, 05:32

It would help you in your future scripts if you get hold of the differences between traditional and expressional syntaxes.
There's this link which explains it quite lucidly http://maul-esel.github.io/ahkbook/en/V ... mands.html
If you still don't get it after going through that, feel free to ask.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: DecimalTurn, Google [Bot], macromint, peter_ahk and 351 guests