Skip to main content

$matches

$matches(string?, regex, flags?) -> boolean
Compact type signature<s-sa<s>?:b>

If string is omitted, the current context value is used.

Browse categories

Source: FUME

Documentation

Tests whether str matches the regular expression string in regex.

The optional flags array supports i for case-insensitive matching, m for multiline matching, and full to require the entire string to match. Empty input strings and empty regex strings return undefined. Invalid regex patterns raise a FUME regex error.

Examples

Match a patient display name case-insensitively

Input

This example uses the patient-summary example input. The expression checks the display name with case-insensitive full-string matching.

Example input

JSON
{
"patientId": "pat-0001",
"name": {
"given": "Avery",
"family": "Reed",
"display": "Avery Reed"
},
"birthDate": "1990-06-12",
"sex": "female",
"primaryCareTeam": {
"organization": "ExampleCare",
"facility": "ExampleCare Clinic",
"practitioner": {
"practitionerId": "prac-4001",
"display": "Jordan Kim"
}
},
"identifiers": {
"memberId": "mbr-3001",
"recordNumber": "rec-5001"
},
"tags": [
"demo",
"fictional"
],
"_xmlTagName": "patientSummary"
}

Expression

$matches(name.display, "avery reed", ["i", "full"])

Result

true