# Patterncount hic !

This topic is 7548 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

When a text field is populated with

"AABGAANAAAAJAAAAAAA"

And I run a count of occurences of "AA", the Patterncount returns 6, while I expected it to return 12.

What I'm trying is use a script that will go to at the last position of a "AA", actually it's right part, then go down by one.

So I expected the script to run as such (bolded is where I want the script to go)

Step 1 : 1- AABGAANAAAAJAAAAAAA

Step 2 : 1- AABGAANAAAAJAAAAAA A

Step 3 : 1- AABGAANAAAAJAAAAAAA

Step 4 : 1- AABGAANAAAAJAAAAAAA

Step 5 : 1- AABGAANAAAAJAAAAAAA

Step 6 : 1- AABGAANAAAAJAAAAAAA

Step 7 : 1- AABGAANAAAAJAAAAAAA

Step 8 : 1- AABGAANAAAAJAAAAAAA

Step 9 : 1- AABGAANAAAAJAAAAAAA

Step 10 : 1- AABGAANAAAAJAAAAAAA

Step 11 : 1- AABGAANAAAAJAAAAAAA

This is used to check and parse what's enclosed "1-" and an "AA"

I resigned and created a Loop which :

- starts from Position of last occurence + (Lenght (textToCheck) -1)

- Goes down one position using a counter

- A SetField[parsed, Case(Middle(text,counter-1,Lenght (textToCheck)) = textToCheck, "someparsing","")

There must be another easy way, isn't it ?

##### Share on other sites

Ugo try

Position(textStr, "AA", 64000 , -1 ) to gain offset of last"AA" in textStr

Dj

Edited: Well actual calculation should be:

Middle(textStr, calc+2+(Left(Middle(textStr, calc+2 , 64000 ), 1) ="A") , 64000 )

Dj

##### Share on other sites

Hmmm...

What calc2 stands for ?

Here's the calc I'm currently using to get the string from start to the Right part of the last occurrence of the "separator"

Middle(textstring,StartPos,Position(textstring,gSep,1,Patterncount(textstring,gsep))+Length(gsep))

Where StartPos could be 1 or any calculated position from another global text field input

gsep is the delimiter ("AA" here)

So I wanted to add a counter and have the calc turned to :

Middle(textstring,StartPos,Position(textstring,gSep,1,Patterncount(textstring,gsep))+Length(gsep)-gCounter)

If the first calc is 'somehow' working, this later doesn't work as with g_counter = 1, the extracted string is :

"AABGAANAAAAJAAAAA" while I expected it to be

"AABGAANAAAAJAAAAAA"

Note that I'm not looking to go down by a simple position-1. I would like the position to move from 1 occurrence.

Example :

If the text string was "AABGAANAAAAJAA", the result should be for gsep = "AA":

g_counter = 0 --> "AABGAANAAAAJAA"

g_counter = 1 --> "AABGAANAAAA"

g_counter = 2--> "AABGAANAAA"

g_counter = 3--> "AABGAANAA"

g_counter = 4--> "AABGAA"

g_counter = 5--> "AA"

g_counter = 6--> " "

...

The result my calc is giving so far is

g_counter = 0 --> "AABGAANAAAAJAA"

g_counter = 1 --> "AABGAANAAAAJ"

g_counter = 2--> "AABGAANAAA"

g_counter = 3--> "AABGAAN"

g_counter = 4--> "AAB"

g_counter = 5--> "AA"

g_counter = 6--> "AAB" !

Is that clear ? Is it what your calc is doing ?

Thanks Dj.

##### Share on other sites

Attached is a little "Text Parser Utility".

You'd better see the problems I'm encountering...

Thanks.

TextParser.fp5.zip

##### Share on other sites

The fixed version, as requested.

TextParser1.zip

##### Share on other sites

This topic is 7548 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account