After ( )

Function stats

Average user rating
3.5000
37
83
9999
Support
FileMaker 7.0 +
Date posted
25 November 2008
Last updated
20 March 2010
Version
Recursive function
No

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

After  ( _text;   _searchString;   _occurrence;   _include_boolean )


Parameters

_text  


_searchString  


_occurrence  


_include_boolean  


Description

Tags:  text parsing  

extracts the end of a text, based on a search string and an occurrence number
occurrence can be positive (starting from the beginning of the text) or negative (starting from the end)

Examples

Sample input

After ( "1234512345" ; "2" ; -1 ; 0 )


Sample output

345

 

Function code

/*
After ( _text ; _searchString ; _occurrence ; _include_boolean )

by Fabrice Nordmann
v.2.3 March 2010
v.2.2 Jan 2010
v.2.1 Sept 2007
v.2, Mar 2007
v.1, Jan 2007

v2 adds inclusion boolean parameter.
v2.1 corrects a bug with searchstring

extracts the end of a text, based on a search string and an occurrence number
occurrence can be positive (starting from the beginning of the text) or negative (starting from the end)

e.g. After ( "1234512345" ; "2" ; -1 ; 0 ) = "345"

see also Before, Between, and BetweenNext functions
*/

Case ( PatternCount ( _text ; _searchString ) ;
Let ([
$cf_occurrence = Case ( not GetAsBoolean ( GetAsNumber ( _occurrence )) ; 1 ; GetAsNumber ( _occurrence ))
; $cf_pos = Position ( _text ; _searchString ; Case ( $cf_occurrence < 0 ; Length ( _text ) ; 1 ) ; $cf_occurrence ) + Length ( _searchString ) - 1
];

Right ( _text ;
Length ( _text ) -
$cf_pos + GetAsBoolean ( _include_boolean ) * Length ( _searchString )
)
))

// ===================================
/*

    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/83

    Prototype: After( _text; _searchString; _occurrence; _include_boolean )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 20 March 2010
    Version: 1.5

*/
// ===================================

 

Comments

Andries Heylen
20 March 2010



Hi Fabrice
you don't kill the two local variables $pos and $occurence after the closing of the custom function. This might be a pitfall when using this function in a script.
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)