06-07-2010, 02:22 PM
(06-04-2010, 01:35 AM)jsknight1969 Wrote:Code:Dim re, teststring, testresults, showresults
teststring = "Ref123"
Set re = new regexp
re.Pattern = "[aA-zZ]"
re.Global = true
re.IgnoreCase = true
set testresults = re.Execute(teststring)
For each match in testresults
showresults = showresults + match.value
Next
msgbox showresults
This works as well using regular expressions. The "execute" method returns a collection of all characters in the test string that match the regex pattern, in this case alphas between A and Z upper or lower case. You must then loop through the collection and concatenate each match to a results string.
JskNight -
Although powerful a function, I would suggest that in the context of QTP this would hamper the test execution if used at several places. The reason being, with the already available string functions supplied by HP dev it seems that the structural programming to link between them works faster than our own. I am just trying to say we minimize the use of loops and other complex regular expressions because QTP's internal engine is weak when it comes to analytical calculations inturn causing load. Unlike perl, phython and other languauges though primitive have a very good engine to perform these operations.
Just a thought.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.