Page 1 of 1

regexmatch help

Posted: 04 Apr 2020, 16:24
by awcrt9316
I am trying to figure out how to recognize if there is a number at the end of a word :headwall: I've used regex before but never quite understood it fully (i am new to ahk)


Code: Select all


if regexmatch(apple + [1-9]) ; if detect a specific word plus a number 1-9

var:= apple ; make var equal to the word without the number




Re: regexmatch help  Topic is solved

Posted: 04 Apr 2020, 16:47
by boiler

Code: Select all

text := "apple8"
RegExMatch(text, "\D+", var)
MsgBox, % var

Re: regexmatch help

Posted: 04 Apr 2020, 16:56
by Chunjee
I think this is similar:

Code: Select all

string := "apple9"
RegExMatch(string, "O)(\D+)\d", UnquotedOutputVar)
msgbox, % UnquotedOutputVar[1]
; => "apple
You can read more about RegExMatch at https://www.autohotkey.com/docs/commands/RegExMatch.htm

Re: regexmatch help

Posted: 04 Apr 2020, 17:20
by awcrt9316
thx for your help!