QTP Forum
Shopmotion


Search
 
 

Display results as :
 


Rechercher Advanced Search

Poll
Keywords

objects  excel  datatable  

Latest topics
» how to extract a filename attached to a user defined field
Fri Apr 19, 2013 1:49 pm by Gajre

» EQP and BVA
Sun Nov 25, 2012 5:55 pm by Gajre

» test optimised testing
Sun Nov 25, 2012 3:59 pm by Gajre

» composite primary key
Sun Nov 25, 2012 2:50 pm by Gajre

» Downloading From ALM
Thu Nov 08, 2012 2:46 pm by Gajre

» Virtual Objects
Thu Nov 08, 2012 2:32 pm by Gajre

» Time Stamp
Tue Nov 06, 2012 11:15 pm by Gajre

» How to generate Random value of any type based on the input
Sat Oct 20, 2012 4:43 pm by Gajre

» If any help required on the QC and QTP APIs, please post your queries...
Fri Oct 19, 2012 11:14 am by Gajre

May 2013
MonTueWedThuFriSatSun
  12345
6789101112
13141516171819
20212223242526
2728293031  

Calendar Calendar

Affiliates
free forum


Using a RegExp object, how to find the match of all occurrences of a search string pattern inside a target string.

View previous topic View next topic Go down

Vote if this topic was useful to you

0% 0% 
[ 0 ]
0% 0% 
[ 0 ]
100% 100% 
[ 1 ]
0% 0% 
[ 0 ]
 
Total Votes : 1

Using a RegExp object, how to find the match of all occurrences of a search string pattern inside a target string.

Post by Gajre on Thu Jul 05, 2012 11:56 pm

''This sub finds the matches in a Input String

Sub RegExpSub(strMatchPattern, strInputPhrase)
'create variables
Dim objRegEx, Match, Matches, StrReturn
'create instance of RegExp object
Set objRegEx = New RegExp
'find all matches
objRegEx.Global = True
'set case insensitive
objRegEx.IgnoreCase = True
'set the pattern
objRegEx.Pattern = strMatchPattern
'create the collection of matches
Set Matches = objRegEx.Execute(strInputPhrase)
'print out all matches
For Each Match in Matches
StrReturn = "Match found at position "
StrReturn = StrReturn & Match.FirstIndex & ", and the Match Value is " & Match.Value
MsgBox StrReturn
Next
End Sub

'call the subroutine
Call RegExpSub("is.", "Is1 is2 Is3 is4")

''Output of execution:
'Match found at position 0, and the Match Value is Is1
'Match found at position 4, and the Match Value is is2
'Match found at position 8, and the Match Value is Is3
'Match found at position 12, and the Match Value is is4

Gajre
Admin

Posts: 34
Join date: 2012-06-17
Age: 30
Location: Hyderabad

View user profile http://qtpelearning.forumotions.in

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum