Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to find a particular text in a text string
#4
Solved: 11 Years, 4 Months ago
You can also use regular expressions.
Code:
Dim re, teststring, testresults, showresults
teststring = "10:2:3:1"
Set re = new regexp
re.Pattern = "(\d*[,|:]){3}(\d*)+"
re.Global = true
re.IgnoreCase = true

'boolean test
msgbox re.Test(teststring)


'Get the actual text
set testresults = re.Execute(teststring)
For each match in testresults
    showresults = showresults + match.value
Next
msgbox showresults

This pattern means: 3 sets of numbers of any length separated by a "," or ":" then a final set of numbers of any length.

Changing the separator or adding alpha characters or adding/removing a separator with digits will return a false.

The "Test" method returns a boolean based on the pattern. The "Execute" method will return an array of characters that match in the pattern that you can then parse to get a particular value or concatenate to return the string.

Regular expressions are quite powerful and can be used for many applications in parsing strings.
Reply


Messages In This Thread
RE: how to find a particular text in a text string - by jsknight1969 - 06-04-2010, 08:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with Text color recognition Treirk 0 1,111 06-17-2019, 12:19 PM
Last Post: Treirk
  How to remove text in the webedit silpavinod 3 13,789 07-12-2018, 11:08 AM
Last Post: vijaychourasiya0109@gmail.com
  text checkpoint properties error alp 0 1,177 11-24-2017, 04:36 PM
Last Post: alp
  How can we get the Windows application Text box background color Using UFT 11.53 Kuppampattu 3 6,030 06-06-2017, 11:12 AM
Last Post: workrohit08
  How to find and change text in PDF document using QTP UFT automation VBscript alexwhite 0 12,060 02-18-2017, 04:20 AM
Last Post: alexwhite

Forum Jump:


Users browsing this thread: 3 Guest(s)