endsWith - Check if a string ends with a given suffix
The endsWith
function returns true
if a given substring appears at the end of a string, and false
if it does not.
Note
This is different from contains
, which will check if a substring appears anywhere within a given string.
Syntax
Like many functions in DataPrime, endsWith
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
string | string | true | The string to test |
suffix | string | true | The suffix that will be tested against the end of the string |
Example - Check if an IBM Cloud CRN refers to a known COS bucket
IBM Cloud CRNs look something like this: crn:v1:bluemix:public:cloud-object-storage:global:a/59bcbfa6ea2f006b4ed7094c1a08dcdd:1a0ec336-f391-4091-a6fb-5e084a4c56f4:bucket:mybucket
If we wish to check if this CDN refers to mybucket
, we can check with endsWith
This will define a new boolean field indicating whether a given CRN value ends with mybucket
.
Theme
Light