Greetings,
I'm a newbie at dxl programming. I'm trying to prepare a script with the following 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:
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!! jmkinki - Wed May 21 10:12:23 EDT 2014 |
Re: DXL - How to find and count a given text in a string? Check out the fourth post in https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014695315&ps=25 Tony |
Re: DXL - How to find and count a given text in a string? I didn't read Goodman's link but I'm sure its pretty good. No doubt you need to put findPlainText in a loop; or use some other searcher. There are some nuances to consider:
In your findPlanText loop, generally I think you want to increment your "offset"
-Louie
|
Re: DXL - How to find and count a given text in a string? Tony_Goodman - Wed May 21 11:18:57 EDT 2014 Check out the fourth post in https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014695315&ps=25 Tony Thank you Tony.
I have tried with this script. It looks like it works fine. However it doesn't work in a bucle. I get the numbers of shall for each object in the module, but not the total number of shall in the module. Any idea to get it?? I have seen the other posts in the same link but that code doesn't work. Some error messages are shown. I have used this code:
|
Re: DXL - How to find and count a given text in a string? llandale - Wed May 21 16:13:18 EDT 2014 I didn't read Goodman's link but I'm sure its pretty good. No doubt you need to put findPlainText in a loop; or use some other searcher. There are some nuances to consider:
In your findPlanText loop, generally I think you want to increment your "offset"
-Louie
Thank you for your answer. Goodman links works for a single string but as I have to look for a complete module... |
Re: DXL - How to find and count a given text in a string? jmkinki - Thu May 22 06:41:59 EDT 2014 Thank you for your answer. Goodman links works for a single string but as I have to look for a complete module... Try this
Module m = current Buffer b = create Regexp re = regexp2"([Ss][Hh][Aa][Ll][Ll])"
for o in m do print(totalCount " shall in " name(m) "\n")
|
Re: DXL - How to find and count a given text in a string? Tony_Goodman - Thu May 22 07:13:15 EDT 2014 Try this
Module m = current Buffer b = create Regexp re = regexp2"([Ss][Hh][Aa][Ll][Ll])"
for o in m do print(totalCount " shall in " name(m) "\n")
Thank you Tony!! This code works fine!! Thank you for your help!! |