# Matches test

Learn how to check if a string matches a regular expression.

This test checks if a string includes another string or matches a regular expression.

When matching a string, the test checks if the string includes the other string. For example, `"Hello world"` matches `"Hello"` and `"lo wo"`, but does not match `"hello"`. The test is case-sensitive, meaning that the strings must match exactly, including the case of the letters.

> **Case-insensitive matching**
>
> You can use the `i` flag to match case insensitively using [regular expressions](/reference/cql/expressions/literals/regex).

## Syntax

This test has the following syntax:

```cql
/*<value>*/ matches /*<pattern>*/
```

To negate the test, you can write:

```cql
/*<value>*/ does not match /*<pattern>*/
```

## Parameters

These are the supported parameters:

- `value`: `string`

  The string to validate.

- `pattern`: `string | regex`

  A string or [regular expression](/reference/cql/expressions/literals/regex) to check if the string matches.

## Examples

Here is a basic example that checks if a string matches another string:

```cql
"Hello world" matches "lo wo" // true
```

You can negate the test to verify the contrary:

```cql
"Hello world" does not match "lo wo" // false
```

You can also use a regular expression to match a string:

```cql
"CQL is powerful" matches ~/^[a-z]{3}/i // true
```

In this example, the test checks whether the string starts with three letters. The `i` flag makes the test case-insensitive.
