Code: Select all
variable = abcd-567 ; or 12abcd-567
if RegExMatch(variable,"((\d|\w)+)-(\d+)",vars)
{
msgbox,% vars1 . "_" . vars2
}
Code: Select all
variable = abcd-567 ; or 12abcd-567
if RegExMatch(variable,"((\d|\w)+)-(\d+)",vars)
{
msgbox,% vars1 . "_" . vars2
}
Code: Select all
variable = abcd-567 ; or 12abcd-567
if RegExMatch(variable,"((?:\d|\w)+)-(\d+)",vars)
msgbox,% vars1 . "_" . vars2
; or
if RegExMatch(variable,"((\d|\w)+)-(\d+)",vars)
msgbox,% vars1 . "_" . vars3
; or
variable = 12abcd-567
if RegExMatch(variable,"(\w+)-(\d+)",vars) ; \w = alpha-numeric
msgbox,% vars1 . "_" . vars2
Sorry my bad, did not make it clear. I want to match the 2 or 3 possabilites (former part could be interger or word or mix) in one code.AlphaBravo wrote: ↑18 Feb 2019, 21:41https://www.autohotkey.com/boards/posting.php?mode=quote&f=76&p=264188#postingbox
Thank you very much, I'll try to learn from this.AlphaBravo wrote: ↑18 Feb 2019, 21:41I am guessing this is what you're looking forCode: Select all
variable = abcd-567 ; or 12abcd-567 if RegExMatch(variable,"((?:\d|\w)+)-(\d+)",vars) msgbox,% vars1 . "_" . vars2 ; or if RegExMatch(variable,"((\d|\w)+)-(\d+)",vars) msgbox,% vars1 . "_" . vars3 ; or variable = 12abcd-567 if RegExMatch(variable,"(\w+)-(\d+)",vars) ; \w = alpha-numeric msgbox,% vars1 . "_" . vars2
Not quite.
RegEx - Quick Reference wrote:\w ... This is equivalent to [a-zA-Z0-9_]. ...
Users browsing this forum: RussF and 377 guests