Brian Dunning's FileMaker Custom Functions

getbetween ( text, starttext, stoptext,occurrence )

gets the text between two search values

  Average rating: 4.2 (33 votes) Log in to vote

Bailey Kessing   Bailey Kessing - Show more from this author
NCI-Frederick
http://kessing.com

Share on Facebook Share on Twitter

  Sample input:
getbetween("cefcbabcdefg", "ab", "ef",1)
  Sample output:
cd

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

This functions allows you to get any text in a field between two search text strings.
Updated 11/12/201 to fix somebugs.
Updated 6/1/2006 to add the ability to get the "stoptext" after the occurence of the "starttext". Before if the stoptext exist both before and after the starttext it would return nothing. Updated 8/2/2006 to add ability to leave off teh start and/or stop position and defaults to the first char and last char.

 

Comments

Bill Doerrfeld   Bill Doerrfeld, Seattle
Oct 16, 2009
Doesn't work.
 
John Davis   John Davis, Houston
Jul 2, 2015
Appears this generally doesn't suffer from the "duplicate sequential values" bug that a lot of these list functions have, however this CF does fail at times.

Given this text:
"Alpha|Charlie|Charlie|Charlie|Charlie's Angles|Mother|Echo"

and using the starttext and stoptext as both "|"

...finding occurrences 1 - 5 return the correct results,
but requesting occurrence 6 returns "Echo", when it should return null,
and requesting occurrence 7 returns the entire original string!


GetTextBetween ( text ; from ; to ; occurrence )
http://www.briandunning.com/cf/584
is the best CF like this that doesn't fail.
 

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: