View raw Markdown
type: fhirpath-functionfunction: matchescategory: String Manipulationsection: 5.6.10source: fhirpath/functions.json

FHIRPath Function: matches

Returns true when the value matches the given regular expression. Regular expressions should function consistently, regardless of any culture- and locale-specific settings in the environment, should be case-sensitive, use 'single line' mode and allow Unicode characters. The start/end of line markers ^, $ can be used to match the entire string.

If the input collection or regex are 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.

The optional flags parameter can be set to: {:.stu}

'http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1'.matches('Library') // returns true
'N8000123123'.matches('^N[0-9]{8}$') // returns false as the string is not an 8 char number (it has 10)
'N8000123123'.matches('N[0-9]{8}') // returns true as the string has an 8 number sequence in it starting with `N`

Summary

Description

Returns true when the value matches the given regular expression. Regular expressions should function consistently, regardless of any culture- and locale-specific settings in the environment.

Arguments

Type Mapping

Example

'http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1'.matches('Library') // returns true
'N8000123123'.matches('^N[0-9]{8}$') // returns false as the string is not an 8 char number (it has 10)