matches
Description
Returns true
if a string matches a given regular expression. The expression is applied to the entire string; partial matches return false
.
Syntax
Like many functions in DataPrime, matches
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
value | string | true | The string to test |
pattern | regexp | true | The regular expression to test against |
Example
Detect malformed fields
Consider the following documents:
{ "msg_structured": "User Chris bought 10 Sunglasses" }
{ "msg_structured": "User James bought 1 Bed" }
{ "msg_structured": "User Rick won't give you up" }
The third entry is incomplete. Use matches
to filter out malformed values:
Output
Theme
Light