Brian Dunning's FileMaker Custom Functions

FindValues ( list ; searchString ; matchcase )

Returns a list of all values from the original list that contain the given search string.

  Average rating: 4.3 (29 votes) Log in to vote

Theo Ros   Theo Ros - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
FindValues ( "Red shoe¶Fred¶Redhead" ; "Red" ; True )

FindValues ( "Red shoe¶Fred¶Redhead" ; "Red" ; False )
  Sample output:
"Red shoe¶Redhead"

"Red shoe¶Fred¶Redhead"

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

Returns a list of all values from the original list that contain the given search string. Unlike FilterValues(), the search string can be part of the value, not the entire value. Furthermore, FilterValues() is always case insensitive, whereas here you can choose.

Syntax: FindValues ( list ; searchString ; matchcase )

In: list - the return delimited list to search
searchString - the string to search for
matchCase - if set to True (any value not equal to zero)
the function does a Case Sensitive search
if False (0) the function behaves Case Insensitive

Return type: Text

Uses function ListIndex() to do the real work of finding a matching item, without the need for recursing through every value in the list.

 

Comments

Tiago   Tiago, Antwerp
Jul 5, 2012
Its a shame that this does not work properly :/ I needed this .

It always returns only the first matching value not all the values on the list.
 
Tiago   Tiago, Antwerp
Jul 5, 2012
After a bit of doodeling , I manage to make it work, delete my previous comment :/
 
Alan   Alan, Cloverdale CA
May 20, 2017
With input of

FindValues ( "(B) test 1 ¶ (F) test 2" ; "(F)";1 )

it returns

F) test 2

missing the "("
 
HOnza Koudelka   HOnza Koudelka, Prague
Nov 9, 2017
It does not work properly when any value starts or ends with a characters that are considered word separators.

Here's a fix:

If ( not IsEmpty ( currlist ) ;
Let ( index = ListIndex ( currlist ; searchString ; matchcase ) ;
If ( index ; // combine what we find with the possible next one
List ( GetValue( currlist ; index ) ; FindValues ( MiddleValues ( currlist ; index + 1 ; 999999999 ) ; searchString ; matchcase ) )
)
)
)
 

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: