nickchapin

Position vs PatternCount

Discussion created by nickchapin on Mar 23, 2018
Latest reply on Mar 26, 2018 by Agnès

There was recently a post about the Position function; it reminded me of what I frequently see with regards to the PatternCount function and I thought I'd remind and reinforce to developers that using the Position function over the PatternCount function in certain circumstances is better.

 

When someone is trying to find out if a bit of text has some specific data in it lots of folks use the PatternCount to look for that - PatternCount ( table::field ; "myText" ) - as a boolean to do something else.

 

A better call is to use the Position function - Position ( table::field ; "myText" ; 1 ; 1 ). Like the PatternCount this will let you know if "myText" exists in the field, but it doesn't have to traverse the entire field to do so; this can be significantly quicker than the PatternCount function if all you're looking for is a boolean answer to see if the text exists.

Outcomes