cancel
Showing results for 
Search instead for 
Did you mean: 

Count how many times a specific word(text) is mentioned in a text

HussainHafath
Level 2
Hi, I have a long text in a Data Item, and I need to count how many times a specific work in that text is repeated. Is it possible with a certain expression, or probably a Code? Example: "Hello my name is Bob and my age is 33" Search word: "my" Result: 2 times Thank you
3 REPLIES 3

John__Carter
Staff
Staff
Hi Hussain - if you Google Regular Expressions you'll find .Net code examples of this. You could also do by searching the text in a loop if you're not comfortable with code.

SachinBais
Level 4
Hello Hussain  It depend on your logic to create a code to calculate the the result i have created a code kindly find it in the below screen shot and the Explanation.                 Let us Consider Data1 Has Text :my name is xxxx my father name is yyyy and my mother name is zzzz .                             Step 1 :  you need the search for the position of the text ""my"" (Expression :[InStr([Data1], ""my"")] store it in variable Position) and it will return 1 then                Step 2 : decision stage :check Position of ""my""(That is 1) is < Length of (Data1)  Expression :[Position]

ShwetaChavan
Level 3
Easiest way would be - 1.simply split the long text by that specific word by using split text action of utility-string object. You will get collection as an output. 2. (number of rows in collection - 1)   would be the required output you want. To get number of rows of collection, use count action of collection business object. It can  be done with just two simple steps instead of writing code.