How to validate a format of an alphanumeric string - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: How to validate a format of an alphanumeric string (/Thread-How-to-validate-a-format-of-an-alphanumeric-string) |
How to validate a format of an alphanumeric string - PrateepKaraval - 11-07-2014 Hello Everyone, I have a webtable with strings as follows: NA / 123456789 REV / 1239359 GEM / G000018017 472 / 1233574 106 / 1233000171 The client wants me to validate the format of the strings above. The format is XX* / XXXX* Rules of Format: MSP Client # / Loan Number .there is a space before and after the / .the MSP # can be 2 or 3 characters of alphanumeric .the / forwardslash is always present between the MSP and Loan # .the Loan Number can be from 4 - 10 characters of alphanumeric With the rules being said I have searched up and down many places to find the appropriate method for my string format check. There were no VBScript functions that were specific to my needs. I then decided to make my own by creating a regular expression string using the Regular expression evaluator and made sure the regexp is matching the string. Here it is: Code: Dim Format As you can see in my code the string "WPP / 1236547896" should match regexp string "\w.*\s\/\s.*", but step is failing for all rows. Please help with this. Thank you RE: How to validate a format of an alphanumeric string - PrateepKaraval - 11-07-2014 Hi Folks, I have solved my problem. Though I will not be able to explain myself, I took a piece of code and experimentally made it plug in with my scenario. Here it is: Code: Dim Format, matches, regexp Please feel free to come up with the best answer, I am still open to any suggestions, thanks -Prateep K. Banglore, India RE: How to validate a format of an alphanumeric string - vinod123 - 11-08-2014 It is good to see that coming with solution for yourself without posting for all small doubts. So keep up the good work |