View raw Markdown
type: fhirpath-functionfunction: lastIndexOfcategory: String Manipulationsection: 5.6.2source: fhirpath/functions.json

FHIRPath Function: lastIndexOf

{:.stu}

Note: The contents of this section are Standard for Trial Use (STU) {: .stu-note }

Returns the 0-based index of the last position substring is found in the input string, or -1 if it is not found. {:.stu}

If substring is an empty string (''), the function returns the length of the string. {:.stu}

If the input or substring is empty ({ }), the result is empty ({ }). {:.stu}

If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment. {:.stu}

'abcdefg'.lastIndexOf('bc') // 1
'abcdefg'.lastIndexOf('x') // -1
'abcdefg'.lastIndexOf('abcdefg') // 0
'abc abc'.lastIndexOf('a') // 4
'0123'.lastIndexOf('') // 4
'0'.lastIndexOf('') // 1
''.lastIndexOf('') // 0

{:.stu}

Summary

Description

Returns the 0-based index of the last position substring is found in the input string, or -1 if it is not found.

Arguments

Type Mapping

Example

'abcdefg'.lastIndexOf('bc') // 1
'abcdefg'.lastIndexOf('x') // -1
'abc abc'.lastIndexOf('a') // 4