QTP data manipulation of phone numbers
Question ID: 104557
0
0

: I am trying to compare 2 phone numbers. I have a number in a data sheet (for example 6788195300) however I the second number stored in many different formats for example:

Phone Number: 678-819-5300
1+(678)819-5300
(678)819-5300
(678)-819-5300

How can I check to see if number in the data sheet is in my application under test?

Marked as spam
Posted by (Questions: 44, Answers: 0)
Asked on July 31, 2012 7:22 am
65 views
Answers (1)
7
Private answer

There are many ways of doing this compare but I have used the following before.


Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches

'Create variable.
Set regEx = New RegExp

' Create a regular expression.
regEx.Pattern = patrn   ' Set pattern.
regEx.IgnoreCase = True 

' Set case insensitivity.
regEx.Global = True

' Set global applicability.
Set Matches = regEx.Execute(strng)

' Execute search.
For Each Match in Matches
   ' Iterate Matches collection.
   RetStr = RetStr & ''Match found at position ''
   RetStr = RetStr & Match.FirstIndex & ''. Match Value is '''
   RetStr = RetStr & Match.Value & '''.'' & vbCRLF
Next   

RegExpTest = RetStr

End Function

phone1=''6788195300''
phone2=''Phone Number: 678-819-5300''
Regphone1=mid(phone1,1,3) & ''.*'' & mid(phone1,4,3) & ''.'' & mid(phone1,7,4)

print  Regphone1
print  RegExpTest(Regphone1, phone2)
Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on July 31, 2012 7:26 am
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top