type: fhirpath-functionfunction: indexOfcategory: String Manipulationsection: 5.6.1source: fhirpath/functions.json
FHIRPath Function: indexOf
Returns the 0-based index of the first position substring is found in the input string, or -1 if it is not found.
If substring is an empty string (''), the function returns 0.
If the input or substring is empty ({ }), the result is empty ({ }).
If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.
'abcdefg'.indexOf('bc') // 1
'abcdefg'.indexOf('x') // -1
'abcdefg'.indexOf('abcdefg') // 0
Summary
- Category: String Manipulation
- Section:
5.6.1 - Return Type:
Integer - Empty Input Result:
empty - Errors on Multiple Input:
true
Description
Returns the 0-based index of the first position substring is found in the input string, or -1 if it is not found.
Arguments
Type Mapping
Example
'abcdefg'.indexOf('bc') // 1
'abcdefg'.indexOf('x') // -1
'abcdefg'.indexOf('abcdefg') // 0