After – FileMaker pro custom functions

NAME
After — extracts text after search string

SYNOPSIS
After ( text ; searchString ; occurrence ; include_1 )

DESCRIPTION
extracts text after search string

/*
After ( text ; searchString ; occurrence ; include_1 )

by Fabrice Nordmann
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
*/
Let ([
    $occurrence = Case ( not GetAsBoolean ( GetAsNumber ( occurrence )) ; 1 ; GetAsNumber ( occurrence ))
  ; $pos = position ( text ; searchstring ; Case ( $occurrence < 0 ; Length ( text ) ; 1 ; $occurrence ) ; $occurrence ) + length ( searchstring ) - 1
];

Right ( text ;
Length ( text ) -
$pos + GetAsBoolean ( include_1 ) * Length ( searchString )
)
)

source: http://www.briandunning.com/cf/643

After – FileMaker pro custom functions