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.
http://dyce.com

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:
5

0

  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.

 

Comments

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 ) ) )

(from: http://www.briandunning.com/cf/908)
 

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 15 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: