Function overview
Prototype
Between (
_text; _searchString1; _occurrence1; _include1_boolean; _searchString2; _occurrence2; _include2_boolean )
Parameters
_text
_searchString1
_occurrence1
_include1_boolean
_searchString2
_occurrence2
_include2_boolean
Description
Tags:
text parsing
extracts the middle of a text in between delimiters, based on a search strings and an occurrence numbers
occurrences can be positive (starting from the beginning of the text) or negative (starting from the end)
see also Before After, and BetweenNext functions
Examples
Sample input
Between ("/abc/def/ghi/" ; "/" ; 2 ; 1 ; "/" ; -2 ; 0 )
Sample output
/def
Function code
/*
Between ( _text ; _searchString1 ; _occurrence1 ; _include1_boolean ; _searchString2 ; _occurrence2 ; _include2_boolean)
by Fabrice Nordmann
v.2, Mar 2007
v.1, Jan 2007
v.2 adds inclusion boolean parameters
extracts the middle of a text in between delimiters, based on a search strings and an occurrence numbers
occurrences can be positive (starting from the beginning of the text) or negative (starting from the end)
see also Before After, and BetweenNext functions
eg.
Between ("/abc/def/ghi/" ; "/" ; 2 ; 1 ; "/" ; -2 ; 0 ) = "/def"
*/
Let ([
_occurrence1 = Case ( _occurrence1 = 0 ; 1 ; _occurrence1 )
; _occurrence2 = Case ( _occurrence2 = 0 ; 1 ; _occurrence2 )
; _p1= Position ( _text ; _searchString1 ; Case ( _occurrence1 < 0 ; Length ( _text ) ; 1 ) ; _occurrence1 ) + not GetAsBoolean ( _include1_boolean ) * Length ( _searchString1 )
; _p2= Position ( _text ; _searchString2 ; Case ( _occurrence2 < 0 ; Length ( _text ) ; 1 ) ; _occurrence2 ) + GetAsBoolean ( _include2_boolean ) * Length ( _searchString2 )
]
;
Middle ( _text ; _p1 ; _p2 - _p1 )
)
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/89
Prototype: Between( _text; _searchString1; _occurrence1; _include1_boolean; _searchString2; _occurrence2; _include2_boolean )
Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
Last updated: 15 May 2009
Version: 1.2
*/
// ===================================
/*__LITBR__Between ( _text ; _searchString1 ; _occurrence1 ; _include1_boolean ; _searchString2 ; _occurrence2 ; _include2_boolean)__LITBR____LITBR__by Fabrice Nordmann__LITBR__v.2, Mar 2007__LITBR__v.1, Jan 2007__LITBR____LITBR__v.2 adds inclusion boolean parameters__LITBR____LITBR__extracts the middle of a text in between delimiters, based on a search strings and an occurrence numbers__LITBR__occurrences can be positive (starting from the beginning of the text) or negative (starting from the end)__LITBR____LITBR__see also Before After, and BetweenNext functions__LITBR____LITBR__eg.__LITBR__Between ("/abc/def/ghi/" ; "/" ; 2 ; 1 ; "/" ; -2 ; 0 ) = "/def"__LITBR__*/__LITBR__Let ([__LITBR__ _occurrence1 = Case ( _occurrence1 = 0 ; 1 ; _occurrence1 )__LITBR__; _occurrence2 = Case ( _occurrence2 = 0 ; 1 ; _occurrence2 )__LITBR__; _p1= Position ( _text ; _searchString1 ; Case ( _occurrence1 < 0 ; Length ( _text ) ; 1 ) ; _occurrence1 ) + not GetAsBoolean ( _include1_boolean ) * Length ( _searchString1 )__LITBR__; _p2= Position ( _text ; _searchString2 ; Case ( _occurrence2 < 0 ; Length ( _text ) ; 1 ) ; _occurrence2 ) + GetAsBoolean ( _include2_boolean ) * Length ( _searchString2 )__LITBR____LITBR__]__LITBR__;__LITBR__Middle ( _text ; _p1 ; _p2 - _p1 )__LITBR__)__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/89__LITBR____LITBR__ Prototype: Between( _text; _searchString1; _occurrence1; _include1_boolean; _searchString2; _occurrence2; _include2_boolean )__LITBR__ Function Author: Fabrice (http://www.fmfunctions.com/mid/37)__LITBR__ Last updated: 15 May 2009__LITBR__ Version: 1.2__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.
Comments
20 February 2009
Case ( _occurrence2 < 0 ; Length ( _text ) ; _p1 )
20 February 2009
I can't find a case where it wouldn't work, have you kept an example?
Thanks !
20 February 2009
<:TBL:=EXPENSE:><:FMPID:=000619:><:Category:=Housing:><:Amount:=35:>
Without the mods, if I used "<:Cat" as search string 1 and ":>" as search string 2, it would not work because your CF would find the occurence of searchstring 2 in the text BEFORE search string 1. The search for string 2 MUST start after the position of string 1.
(Edited by BruceR on 20/02/09 )
20 February 2009
then it may be a documentation issue, because what you want is precisely what BetweenNext is doing http://www.fmfunctions.com/fname/betweennext
Indeed I use it far more often than Between.
(Edited by Fabrice on 20/02/09 )