It Matches With Occurrence of Char Ex: Ca.r Car (Wrong) Caar Cabr

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 7

Regular Expressions

A Regular Expression is a String that Contains Wild Character which Enables QTP Check For a text String with Varying ( Changeable ) Values or Identify the Objects with Changeable Properties .

Whiled Characters Used with Regular Expression :

. it Matches with 1 occurrence of any Char Ex : ca.r car ( Wrong ) caar cabr --------------------------------------------* it Matches with 0 or More occurrence of preceding Char Ex :

Ca*r cr car caar caaar --------------------------------------------.* it Matches with 0 or More occurrence of Any Char Ex : Logout .* Logout A Logout B Logout AB Logout ABC --------------------------------------------? it Matches with 0 or One occurrence of preceding Char

Ex : Ca?r cr car caar ( Wrong ) caaar ( Wrong ) --------------------------------------------+ it Matches with 1 or More occurrence of preceding Char Ex : Ca+r Cr ( Wrong ) car caar caaar

--------------------------------------------[ABC] it Matches with Any one Chr Specified in The List Ex : QTP[ABC] QTPA QTPB QTPC 200[789] 2007 2008 2009

--------------------------------------------[^ABC] it Matches with Any one Chr Except in The Specified List Ex : QTP[^ABC] QTPA ( Wrong )

( Wrong ) ( Wrong ) QTPD ( Correct ) QTP ( Correct ) --------------------------------------------[A-Z] it Matches with Any one Upper Case Alphabet Ex : QTP[A-Z] QTPA QTPB QTPC QTPZ --------------------------------------------[a-z] it Matches with Any one Lower Case Alphabet Ex :

QTPB QTPC

QTP[a-z] QTPa QTPb QTPc QTPz --------------------------------------------[0-9] it Matches with Any one Numeric Ex : QTP[0-9] QTP0 QTP1 QTP2 QTP9 --------------------------------------------Note :

Regular Expression to Validate Alphabets Only


1)

[A-Z a-z]* [A-Z a-z]+


2)

it Allows Null Values Along with Alphabets

it Allows Only Alphabets

Regular Expression to Validate Alphanumeric Only

[A-Z a-z 0-9]*


Alphanumeric

it Allows Null Values Along with

[A-Z a-z 0-9]+

it Allows Only Alphanumeric

You might also like