8 Replies Latest reply on May 17, 2012 8:56 AM by mbraendle

# PatternCount and Position don't detect overlapping repeats?!?

I'm mystified by the following behavior:

PatternCount( "xxx" ; "xx" ) returns 1. (I would expect 2.)

Position obviously uses the same pattern-matching algorithm:

Position( "xxx" ; "xx" ; 1 ; 1 ) returns 1. (OK.)

Position( "xxx" ; "xx" ; 1 ; 2 ) returns 0. (I would expect 2.)

Assuming non-overlapping repeats seems pretty limiting to me, and I'm finding it difficult to believe. Am I missing the obvious?

• ###### 1. Re: PatternCount and Position don't detect overlapping repeats?!?

I actually find the current behavior intuitive. Are there equivalents of PatternCount( ) and Position( ) in other languages/developing environments where overlapping repeats are taken into consideration?

• ###### 2. Re: PatternCount and Position don't detect overlapping repeats?!?

Test with non-repeating characters to see the logic.

Enter "xoxoxoxoxoxoxoxo" and search for "xo"; it finds the "xo" set 8 times.

Change the "o" to an "x", enter "xxxxxxxxxxxxxxxx", and search for "xx". Again, 8 sets of "xx" are counted.

I believe the logic is that once a set has been counted [the first xx], it does not *double-back* to begin at position 2, but looks for the next instance of "xx", which is found starting at position 3.

In your example, the first "xx" is counted and counting begins anew at position 3. There is not another instance of "xx" from that point forward.

• ###### 3. Re: PatternCount and Position don't detect overlapping repeats?!?

From the FileMaker Help:

PatternCount(“Mississippi”;“issi”) returns 1 (the function isn’t inclusive).   (bold format by me)

These are the little things that are often overlooked in the FileMaker Help and should be written down more clearly. All the information is usually there, but one has to read very carefully to not miss a detail. Something that should be reported in the current survey about FileMaker documentation.

• ###### 4. Re: PatternCount and Position don't detect overlapping repeats?!?

oooo, a FEATURE REQUEST (additional parameter - boolean):

patternCount ( text; searchStr; start; occurrence; case )

if 'case' is 0 or NULL (default) then case doesn't matter. if 'case' is 1, the search by case.

But I'm not sure I'd want inclusive.

Beverly

• ###### 5. Re: PatternCount and Position don't detect overlapping repeats?!?

Oops, Beverly, you mixed up the parameters of PatternCount and Position!

• ###### 6. Re: PatternCount and Position don't detect overlapping repeats?!?

Coffee! Need coffee. LOL

-- sent from my iPhone4 --

Beverly Voth

--

• ###### 7. Re: PatternCount and Position don't detect overlapping repeats?!?

Position ( text; searchStr; start; occurrence; case )

PatternCount ( text; searchStr; case )

Thanks, Martin!

Beverly

• ###### 8. Re: PatternCount and Position don't detect overlapping repeats?!?

Must have been strong coffee ...