X70 Posted July 27, 2020 Posted July 27, 2020 Hi, i'm new to AutoIT scripting. I have a basic question, I want to verify partial of the output and I'm not sure how to this. For example: Output = B1234567890 Need to verify: B12345 Appreciate any of your help
Subz Posted July 27, 2020 Posted July 27, 2020 Try https://regexr.com/ for example you could use something like: ^([A-Z][0-9]{5,5})
X70 Posted July 27, 2020 Author Posted July 27, 2020 1 hour ago, Subz said: Try https://regexr.com/ for example you could use something like: ^([A-Z][0-9]{5,5}) Thanks Subz but could you please elaborate more on the function? I'm quite new to this
Guest Posted July 27, 2020 Posted July 27, 2020 (edited) 1 hour ago, X70 said: ... but could you please elaborate more on the function? I'm quite new to this It depends on what you are looking for : ; Output = B1234567890 ; Need to verify : B12345 Global $sOutput, $sMatch, $bVerified $sOutput = "B1234567890" $sMatch = "B12345" ; Example 1. Check : Output starts with a letter (A..Z) followed by 5 numbers(0..9) $bVerified = StringRegExp($sOutput, "(?i)^([A-Z])\d{5}") If $bVerified Then ConsoleWrite("+ EX 1. ==> Verified" & @CRLF) Else ConsoleWrite("! EX 1. ==> Not Verified" & @CRLF) Endif ; Example 2. The first 6 characters must match exactly : $bVerified = StringRegExp($sOutput, "(?i)^" & $sMatch) If $bVerified Then ConsoleWrite("+ EX 2. ==> Verified" & @CRLF) Else ConsoleWrite("! EX 2. ==> Not Verified" & @CRLF) Endif ; Example 2.1. : for exact match, you could also use StringLeft() If StringLeft($sOutput, 6) = $sMatch Then ConsoleWrite("+ EX 2.1. ==> Verified" & @CRLF) Else ConsoleWrite("! EX 2.1. ==> Not Verified" & @CRLF) Endif Edited July 27, 2020 by Musashi
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now