ends_ with
On this page
Tests whether a string ends with another string.
Syntax
ends_with(<string>, <suffix>)Arguments
| Argument | Type | Description |
|---|---|---|
<string> | string | String to test. |
<suffix> | string | Suffix to match. |
Returns
Returns boolean: TRUE if <string> ends with <suffix>, otherwise FALSE. Returns NULL if either input is NULL. An empty <suffix> matches every non-NULL string.
Examples
Filter file events to PDF receipts using the path suffix.
VALUES
('/receipts/order-17.pdf'), ('/receipts/order-42.pdf'), ('/uploads/cart.jpg')
SELECT $0 AS path
WHERE ends_with(path, '.pdf')
SELECT path+------------------------+
| path |
+------------------------+
| /receipts/order-17.pdf |
| /receipts/order-42.pdf |
+------------------------+Normalize case first if file extensions arrive with inconsistent capitalization.