# String functions

String functions filter resources based on text values in supported fields.

Use them inside `$filter` expressions.

## Supported functions

| Function        | Meaning                                          | Example                             |
| --------------- | ------------------------------------------------ | ----------------------------------- |
| `contains`      | Matches values that contain a substring.        | `contains(prod_title,'EC')`       |
| `startswith`    | Matches values that start with a prefix.        | `startswith(cat_ref,'C')`         |
| `endswith`      | Matches values that end with a suffix.          | `endswith(prod_ref,'-EN')`        |

## Syntax

```text
FUNCTION_NAME(PROPERTY_NAME,'VALUE')
```

## Examples

```http
GET https://api2.saleslayer.com/catalog/Products?$select=prod_ref,prod_title&$filter=contains(prod_title,'EC')
```

```http
GET https://api2.saleslayer.com/catalog/Categories?$filter=startswith(cat_ref,'C')
```

```http
GET https://api2.saleslayer.com/dam/images?$filter=contains(reference,'product')
```

## Combining with logical operators

String functions can be combined with logical operators:

```text
startswith(cat_ref,'C') and contains(cat_title,'Shoes')
```

## Notes

* Use string functions only with fields that support text filtering.
* Use metadata endpoints to confirm field names and data types.
* URL encode query values when necessary.
