Count how many times a specific word(text) is mentioned in a text
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
21-02-18 02:15 PM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
21-02-18 04:03 PM
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.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
21-02-18 05:30 PM
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]
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
23-02-18 12:12 PM
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.
