Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regex works but how do i return the found string to a variable
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Maybe a simple question, so apologies in advance.

I have the following:

Code:
response ="blablahTO-001-A-01blahblablah"

Set oRegExp = New RegExp
oRegExp.IgnoreCase = True
oRegExp.Global=False
oRegExp.Pattern="([A-Z]{2})-([0-9]{3})-([A-Z]{1})-([0-9]{2})"

Msgbox oRegExp.Test(response)

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)
this sets string to true, but i want string to be set to TO-001-A-01

but I don't know which function will return the found pattern?

Does anyone know how to assign the found pattern to the variable?
Reply


Messages In This Thread
regex works but how do i return the found string to a variable - by jove1776 - 08-24-2011, 03:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  WebElement not found in OR mv8167 6 6,035 03-27-2012, 09:10 PM
Last Post: mv8167
  ReGex not working for Java Items jimrazak 0 2,207 02-23-2012, 06:17 PM
Last Post: jimrazak
  Return the last number of “Test” mv8167 4 3,758 02-07-2012, 03:40 AM
Last Post: mv8167
  Turn Off RegEx mv8167 4 4,728 09-27-2011, 10:20 PM
Last Post: mv8167
  QTP 9.2 RegEx issue ashv 2 3,834 02-20-2011, 12:48 PM
Last Post: ashv

Forum Jump:


Users browsing this thread: 3 Guest(s)