Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reg Expression_In Detail
#1
Solved: 11 Years, 4 Months ago
Hi all,
One thing always confusing me hw can i use Reg Expression?What is ways to use?
Pls Expalin me in detail with a scenario ,iam v much confusing me alot .

Pls all post your valuable suggestions,will feel great
Reply
#2
Solved: 11 Years, 4 Months ago
whenever you need to identify an object which is dynamic, that means the values (on which identification depends on) are varying quite often then in that case we should use regular expression.
e.g. lets have a scenario where we need to test on a webpage, the identification of this will depend on the url of the page.
say the url is 'http://Server1/App1/Page1.aspx
Now what if the server loacation has been changed, the url for page will be changed, say - now it is 'http://Server2/App1/Page1.aspx'

In such case if we have not used regular expression, then our script will not proceed furher or use SI
to avoid this we will now put regular expression for page url in our repository - which will be something like - http.*//Server.*/App1/Page1.aspx
while doing this we should concider all possible values which may vary and put a regualr expression for this.

In the same way if you have an dialog box which are varying with the caption e.g. 'Application1 - Microsoft Internet Explorer'
and the Application1 is somthing which is not certain and varying in such case we could use - '.*Microsoft Internet Explorer'

Regular expression can be used for many cases and many ways in your script, another example for this would be a case where you need to validate an alphanumeric value, take a look on the code below which will validate a value 'AaZz09' is alphanumeric or not
Code:
Set regEx = New RegExp         ' Create regular expression.
  regEx.Pattern = "[a-zA-Z0-9]"         ' Set pattern.
  'regEx.IgnoreCase = False      ' Set case sensitivity.
  retVal = regEx.Test("AaZz09")

if retVal  then
  msgbox "Alpha numeric validation passed"
else
  msgbox "Alpha numeric validation failed"
end if

here we have used pattern to validate the value.

I hope this will help you clear your confusions now. if not please let me know your exact issue.
follow QTP help and this nice article for more info on this

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Descriptive programming and Reg Expression sqadri 3 3,046 02-01-2012, 07:37 AM
Last Post: rajpes
  Reg the QTP Add on for Microsoft Dynamic CRM Samudrala 0 3,296 11-12-2011, 09:47 PM
Last Post: Samudrala
  Detail info about createObject() nandu 1 4,117 11-30-2010, 10:36 AM
Last Post: Saket
  Reg: Instances in QTP keerthana 2 3,627 06-21-2010, 02:39 PM
Last Post: keerthana
  Unable to get the values from oracle 10g form detail block ravick16 0 2,396 07-15-2009, 02:42 AM
Last Post: ravick16

Forum Jump:


Users browsing this thread: 1 Guest(s)