Brian Dunning's FileMaker Custom Functions

FirstMatchIndex ( values ; string )

Returns the index of the first value that contains the search string.

  Average rating: 4.0 (25 votes) Log in to vote

Richard Dyce   Richard Dyce - Show more from this author
Dyce & Sons Ltd.

Share on Facebook Share on Twitter

  Sample input:
FirstMatchIndex ( "abc¶023¶abc¶def¶123¶def"; "12")

FirstMatchIndex ( "abc¶023¶abc¶def¶123¶def"; "XYZ")
  Sample output:


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

A quick function to return the index of the first value in 'values' that contains the search 'string'. If the string isn't found returns 0.



comment   comment, VR
Feb 26, 2016
FirstMatchIndex ( "Alfred¶Betty¶Fred¶George" ; "Fred" ) returns 1 instead of the expected 3. This is because you're not testing for the position of the string *as a value*.

Try instead:

ValueCount ( Left ( values ; Position ( ¶ & values & ¶ ; ¶ & string & ¶ ; 1 ; 1 ) ) )

Richard Dyce   Richard Dyce, Dyce & Sons Ltd.
Mar 25, 2020
Err, no. If that's what you want, try or ; This function specifically is looking for a partial match. Returning 1 is precisely what "first value in 'values' that contains the search 'string'" is meant to mean - hence the 'contains'. ;-)

Log in to post comments.


Note: these functions are not guaranteed or supported by 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 16 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: