I've tested my regular expression in http://www.regextester.com/
([0-9]{4,4})([A-Z]{2})([0-9]{1,3})
It's matching perfect with the following strings just as I want it.
1234AB123
2000AZ20
1000XY753
But when I try it in Autohotkey I get 0 result
test := RegExMatch("2000SY155","([0-9]{4,4})([A-Z]{2})([0-9]{1,3})")
MsgBox %test%
testing for:
- first 4 characters must be a number
- next 2 characters must be caps letters
- next 1 to 3 characters must be numbers
You had to many ( )
This is the correct implementation:
Edit:
So what I noticed is you want this pattern to match, but you aren't really telling it much.
Here's what I was able to come up with that matches what you asked for, it's probably not the best solution but it works:
Breaking it down:
So by adding Circumflex we are requiring that our Pattern
[0-9]{4,4}
be at the beginning of the our Haystack.Our next Pattern is looking for two Uppercase Alpha Characters
[A-Z]{2}(?![0-9]{4,})
that does not have four or more Numeric characters after it.And finally our last Pattern that needs to match one to three Numeric characters as the last characters in our Haystack
[0-9$]{1,3}