using variable in RegExMatch

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest

using variable in RegExMatch

23 Oct 2017, 12:39

What is the correct way to do the following?

Zone = ^#.*z39
If RegExMatch(A_LoopReadLine, "%Zone%")

The above does not work but the below does

If RegExMatch(A_LoopReadLine, "^#.*z39")

Thank you
Guest

Re: using variable in RegExMatch

23 Oct 2017, 13:04

After further searching I think I have figured it out as it seems to work.

2 ways to go about it:

Code: Select all

Zone = ^#.*z39
If RegExMatch(A_LoopReadLine, "" . Zone . "")
or

Code: Select all

Zone = 39
If RegExMatch(A_LoopReadLine, "^#.*z" . Zone)
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: using variable in RegExMatch

23 Oct 2017, 13:16

Hello.

Code: Select all

Zone := "^#.*z39"
If RegExMatch(A_LoopReadLine, Zone) 
Please see variables and expressions. You might find the tutorial useful.

Cheers.
Guest

Re: using variable in RegExMatch

31 Oct 2017, 17:44

So Ive been using:

Code: Select all

Zone = 39
If RegExMatch(A_LoopReadLine, "^#.*z" . Zone)
which is working fine, but now I need to add a \s for a space after Zone
I am having a difficult time figuring out how to do this.
Ive tried the obvious which does not work:

Code: Select all

Zone = 39
If RegExMatch(A_LoopReadLine, "^#.*z" . Zone\s)
Any help is appreciated. Thank you
User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: using variable in RegExMatch

31 Oct 2017, 22:20

What really should be obvious is to but the literal string part in quotes as was done with the other part.

Code: Select all

Zone = 39
If RegExMatch(A_LoopReadLine, "^#.*z" . Zone . "\s")
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: using variable in RegExMatch

01 Nov 2017, 07:01

If you're having trouble with using Functions, do remember that all Functions use Expression mode for their parameters.
For example:

Code: Select all

Text = Hello world!	; Message of "Hello World!"
Title = Message Box	; Title of "Message Box"
Options = 0	; Just the OK button
Timeout = 0	; Timeout is infinite
MsgBox(Text, Title, Options, Timeout)

MsgBox(Text := "", Title := "", Options := "", Timeout := "") {
	MsgBox, % Options, % Title, % Text, % Timeout
}

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder and 53 guests