Brian Dunning's FileMaker Custom Functions

ContainsExact ( Text ; SearchStrings )

checks whether at least one of the values in SearchValues is an exact match for a portion of Text

  Average rating: 3.5 (2 votes) Log in to vote

Bill Thurmes   Bill Thurmes - Show more from this author
MDCA
http://www.miyotadca.com

Share on Facebook Share on Twitter

  Sample input:
ContainsExact ( "CA" ; "GA;FL;MN;CA" )
ContainsExact ( "LeBron James" ; "Lebron" )
ContainsExact ( "Jim,Jane" ; "m\,J" )
  Sample output:
1
0 (not the same capitalization)
1

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Purpose: Determine whether Text contains any of the strings contained in SearchStrings ('or' logic) and that those strings are exact matches (useful when ESQL queries depend on the function). I found it useful, in concert with TableNames, LayoutNames, and conditional formatting, to determine whether entries for layout or table names were capitalized correctly.
Similar to Position function but will assess several SearchStrings, gives 0 or 1 (No or Yes) as Result
Restriction: the following !-containing strings may not be part of SearchStings: !c! !s! !p!
4/27/17 - A shortcoming of this occurred to me: this only checks the first incidence of the SearchStrings value in Text. Thus, ContainsExact ("Remark Mark"; "Mark") would evaluate as 0 because the first "mark" is not an exact match for the SearchString. I haven't yet come up with a fix for this. 4/27/17 - Solved it! Combo of Substitute & PatternCount

 

Comments

Dick Impens   Dick Impens, MaltaCode
Dec 28, 2021
There is a slight problem when searching for numbers;

2nd floor flat 2 will return a 1 when using the function;
3rd floor flat 3 will return a 0 when using the function;
2nd floor flat 3 will also return a 1 (as the first number is a 2)
but this is a word ("2nd", no spaces) so it should not be a exact match.

Is this something that can be resolved in the function?
 
Dick Impens   Dick Impens, MaltaCode
Dec 28, 2021
Even FM will see it as 1 word;
LeftWords ( "2nd floor flat 3" ; 1 ) will return "2nd"
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: