regex works but how do i return the found string to a variable - 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: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions) +--- Thread: regex works but how do i return the found string to a variable (/Thread-regex-works-but-how-do-i-return-the-found-string-to-a-variable) |
regex works but how do i return the found string to a variable - jove1776 - 08-24-2011 Maybe a simple question, so apologies in advance. I have the following: Code: response ="blablahTO-001-A-01blahblablah" I get a popup saying that it is found i presume that the correct way to get the string is something like Code: string = oRegExp.Test(response) but I don't know which function will return the found pattern? Does anyone know how to assign the found pattern to the variable? RE: regex works but how do i return the found string to a variable - jove1776 - 08-24-2011 Ok I managed to get it to work using the following I found on the net: Code: Dim re, testresults, showresults Unfortunately I didn't realize in the string i was searching there are 28 separate matches for that search which are all valid but all different. I just need the very last instance of the match for my purposes. Does anyone know what the regex is for this? I am a bit new to regex RE: regex works but how do i return the found string to a variable - jove1776 - 08-24-2011 I managed to solve the issue by using the string function right to cut down the string. I then used the regex to search for that pattern. i bet you could do this with regex to match the last instance, please let me know if it is possible, as my code is a bit of a beginners messy code |