Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to separate a string
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
(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.
Reply


Messages In This Thread
How to separate a string - by linhke - 05-28-2010, 03:26 PM
RE: How to separate a string - by guin.anirban - 05-28-2010, 03:50 PM
RE: How to separate a string - by jsknight1969 - 06-04-2010, 01:35 AM
RE: How to separate a string - by basanth27 - 06-07-2010, 02:22 PM
RE: How to separate a string - by jsknight1969 - 06-07-2010, 10:54 PM
RE: How to separate a string - by basanth27 - 06-08-2010, 08:49 AM
RE: How to separate a string - by jsknight1969 - 06-09-2010, 12:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to have a variable that has a string comma string .. shareq1310 5 5,070 11-09-2011, 03:33 PM
Last Post: parminderdhiman84
  string function to get a letter from a string ajay.r1982 3 7,569 06-30-2009, 08:58 PM
Last Post: Ankur

Forum Jump:


Users browsing this thread: 3 Guest(s)