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}
ito perform a case-insensitive search (otherwise is case-sensitive)m- Matches the start and end of each line using ^ and $ (multi-line)<br/>(not only begin/end of string) {:.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
- Category: String Manipulation
- Section:
5.6.10 - Return Type:
Boolean - Empty Input Result:
empty - Errors on Multiple Input:
true
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
regex:String- Regular expression to match againstflags(optional):String- Optional flags for the regex (i for case-insensitive, m for multi-line)
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)