contains
Description
Returns true if the given substring appears anywhere in a string; otherwise return false. The check is case sensitive. For case-insensitive matching, normalize both values with toLowerCase() or toUpperCase() before calling contains.
Syntax
Like many functions in DataPrime, contains supports two notations, function and method. These interchangeable forms allow flexibility in how you structure expressions.
- Function notation
- Method notation
contains(value: string, substring: string): bool
(value: string).contains(substring: string): bool
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
value | string | true | The full string to search (haystack) |
substring | string | true | The substring to look for within the full string (needle) |
Example 1
Check if an AWS Account ID appears in an ARN
Sometimes only a broader field such as an ARN is available. Use contains to test for the presence of the account ID.
Example query
- Function notation
- Method notation
create is_from_account from contains(arn_field, '074157727657')
create is_from_account from arn_field.contains('074157727657')
Example output
Both notations produce a field is_from_account that is true if the ARN contains the account ID.
Example 2
Use case 2: Check if a domain appears within a URL
Use contains to verify if a domain name exists inside a given URL.
Example query
- Function notation
- Method notation
create is_from_google from contains(url, 'google.com')
create is_from_google from url.contains('google.com')
Example output
Both notations produce a field is_from_google that is true if the URL contains google.com.