Brian Dunning's FileMaker Custom Functions

get_text_part_between_opener_and_closer ( text ; opener ; opener_occurrence ; closer ; error_indicator )

Extracts the part of text between opener ( that is opener's opener_occurrence ) and the first closer after closer.

  Be the first to rate this function Log in to vote

Frank van der Most   Frank van der Most - Show more from this author
Rubber Boots Data
https://rubberbootsdata.com

Share on Facebook Share on Twitter

  Sample input:
get_text_part_between_opener_and_closer ( "abcdabefghijk" ; "ab" ; 2 ; "ij" ; "??" )
  Sample output:
efgh

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

From text, gets the part between the opener_occurrence occurrence of opener and the first of occurrence of closer after opener
If IsEmpty ( closer ) then the result is everything after the opener_occurrence occurrence of opener
If IsEmpty ( opener ) then the result is everything before the closer

Since the text parameter can contain any text, it is hard to come up with a universal error indicator. Hence the error_indicator parameter.


Perhaps similar functions already exist in the database. I could only find ExtractPortion, which seems too simple.

I wrote this function to retrieve text from a URL but there are of course plenty of applications.

I have tested the function somewhat, but perhaps there are situations that would slip past the safety test.

My only regret with this function is that FM's position function is not case sensitive. Fortunately, there are solutions for that in this database.

If you release the comment with test parameters, you can run the function also in the data viewer or use it directly in a calculation.

 

Comments

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: