This site requires JavaScript to be enabled
IE BUMPER

Tosca Version
IncidentLookup using list
Language
Your Question
  Help
IE BUMPER
Product
Results per page
Tosca Version
Categories
Version
Boolean Operators
OR or vertical bar symbol (|)
Finds a match if either the terms exist in a document (a union using sets).
AND
Finds a match if both terms exist in a document (an intersection of sets).
NOT, minus (-), or exclamation point (!)
Excludes documents that contain the term after NOT (a difference of sets).
Wildcards
Asterisk (*)
The asterisk symbol performs a multi character wildcard search.
Percent sign (%)
The percent sign performs a single character wildcard search.
Phrases
Quotation marks (")
Use quotation marks to search for an exact phrase with multiple terms.
For examples and more information look at our Knowledge Base: Advanced Search On The Support Portal

Retrieve number of times a word occurs with in a string

Hello,

Can someone suggest me the steps to retrieve number of times a word occurs with in a string and store it in a buffer?

Thank you

Mohinuddin Patel

 

4 0

David Hämmerle

Created: 2016-06-11 13:32:14

Hello Mohinuddin,

if you have Excel installed on your workstation then you can use CALC expression to get the number in question. The basic idea of this CALC expression is to remove the string to be searched for from the complete string and use the difference in length to calculate the number of occurrences.

Formula: Let A denote the complete string, B the word to be counted, and N the number of times B occurs in A. Then the formula is given as

N = (Lenght(A) - Length(A without B))/Length(B).

The corresponding CALC expression using a classic TestStep is 

{CALC[(LEN("A")-LEN(SUBSTITUTE("A", "B", "")))/LEN("B")]}

Since 9.1 it is also possible to use CALC within XTestSteps for which the corresponding expression is given as

{CALC[(LEN(""""A"""")-LEN(SUBSTITUTE(""""A"""", """"B"""", """""")))/LEN(""""B"""")]}

I hope this answers your inquiry.

6 0

Rahul S S

Created: 2016-06-12 14:07:14

Hi Patel,

Apart from what David correctly suggested, there are few more options available in TOSCA for your use case. Just wanted to explain another very easy method to do this.

There is a generic module called "TC String Operations". Using this module you should be able to search for the number of occurences of a string in another string (there are lot more you could do with this module). This is how it should be done:

In the above example, I am trying to search for the pattern "I" in a buffer variable called "String" (which has some ramdom text stored in it). In the result, I am using the count syntax to count the number of occurances. The whole string is searched for "I" and the result is stored in a variable called "Count" (using dynamic buffer).

Note: For the "Operation" parameter, it is also possbile to ignore the case of the string/character specified in "Pattern",for that the synatx would be - Search,Global,IgnoreCase

Best Regards,

Rahul

0 0

Patel Mohinuddin

Created: 2016-06-13 17:07:42

Thank you David and Rahul, both the solutions works

 

Regards,

Mohinuddin, Patel

IE BUMPER

Tosca is the perfect solution

Optimize - Manage - Automate

Download Trial