Dear all,
I have been using AHK for a while and getting more into scripting.
I'm trying to get AHK to get a number from the subject line of an email.
The subject line may be "Re: information on 22897654" or "question concerning 88355667" or something like that.
To do this I have used WinGetTitle to convert the current window title in ms outlook to a string
Then I want AHK to only find the number in this string and save this as a new string. There will only be one such a number in the string
This number always consists of 8 characters, e.g. 12345678 or 22345678
By searching online, I found that RegEx may be an option, but when I look into it I can't find how to exactly use it.
Do you have any suggestions?
Thanks a lot,
best,
Justin
finding a number in a string Topic is solved
Re: finding a number in a string
Example:
Code: Select all
F1::
linestring := "Re: information on 22897654"
Getnumbers := RegExReplace(linestring, "\D") ;Get only the numbers from a string
MsgBox, % Getnumbers
Return
If I was helpful consider Donate me. , plz
Re: finding a number in a string
Thanks w0z, I’m sure this will work.
However is it also possible to restrict RegEx to an 8 digit number? Just in case that there are multiple numbers in the original string? (And just one 8 digit number?)
Best, Justin
However is it also possible to restrict RegEx to an 8 digit number? Just in case that there are multiple numbers in the original string? (And just one 8 digit number?)
Best, Justin
Re: finding a number in a string Topic is solved
Code: Select all
linestring := "Re: 123 - information on 22897654"
RegExMatch(linestring, "\d{8}", match) ;Get only the 8 digits from a string
MsgBox, % match