I want to find a text string in a given column for each object, and count how many times that string is repeated.
For example, I would like to define as string column "XX", and I would like to find the text "hello" in column "XX" for all objects.
Further to it I want each time that "hello" is find, it should be counted in order at the end of the script, the total ammount of "hello" shall be shown.
I have tried to use command findPLainText, but once the text "hello" is find in a object, it stops. So whether in a same object for example "Hello here you have 2 hello", once the first text has been found the second ones isn't searched or counted.
How I can do it?
Thank you in advance for your help!!
Edit: I have divided all this in 3 tasks:
1.- Extract text for some columns in order to define a string for each object.
2.- Define a second string I'm looking for inside that columns text.
3.- Count how many times the second string has been found.
I have complete the 2 first tasks:
int n=0
Column c
Object o
Module m
Buffer b = create
for o in document m do {
b = text(column 0, o) text(column 1,o) text(column 2,o)
string s = stringOf b
string sub ="XXX"
if (findPlainText(s, sub, offset, len, true)) { n += 1 }
}
print n
With this I get text from columns 0, 1 and 2, put together in a same string. After that I define the text I'm looking for "XXX". And entire n gives me how many times it is found.
However this script doesn't work properly becuase once the text is found first time in a given object, it continues with the following object. So the text it is only found once for each object. However whether the same text "XXX" it is include many times at the same string s I can't count it (for example, whether s="XXX and XXX but XXX", this script counts 1 instead 3.
Could somebody helps me, correcting the script?
Thank you in advance for your help!!