# String searching

AQL permits the use of string searching (sometimes called wildcards), that allows
 introducing variables into the selection criteria. Consider the sentence:

```
 list entity with city = "irv]" city
```

 The right-bracket specifies that any character, or characters, may follow the literal string,
 `irv`. This means that both irvine and irving are selected. Consider the
 sentence:

```
list entity with name "[inc."
```

 Any item whose name attribute ended with inc. is eligible for processing.

 The bracket (string searching) characters may also state an *including* or
 *containing* condition, as in the form:

```
list entity with name = "[rain]"
```

 This includes in the report any item whose name attribute contains the string
 `rain`. This includes Raining, All Terrain Vehicles, and The First Rain.

## Example(s)

In this selection criteria, only those items whose name field begins with `ar`
 are selected.

```
list entity with name "ar]" name
```

 This example shows two selection clauses connected with an and, which means
 that both conditions must be evaluated as true in order for the items to be selected for
 processing.

```
list entity with name "mi]" and with phone "804]"
```

 This example shows a mutually exclusive set of selection criteria connected with an
 or. Either condition evaluating to true accepts the item for processing.
 That is, if the name attribute begins with `ar`, or the city attribute begins
 with `irv`, the item is selected for output.

```
list entity with name "re]" or with city "irv]" name city
```

 There is virtually no limit to compound selection criteria in an AQL sentence, with the
 exception of the fact that AQL limits a sentence to a maximum of 9 and
 clauses.

```
list entity with name "ar]" and with city "irv]" or with city "san]" and with
contact "[joe]"
```

 Wildcard characters may be used to select item-IDs and attributes based on common characters.
 Wildcards can be used in selection criteria or complex item-lists as follows:

| [ | Matches characters following the bracket. Ignores characters to the left of the bracket. |
| --- | --- |
| ] | Matches characters from the beginning of the string to the bracket. Ignores the characters to the right of the bracket. |
| ^ | Matches any character in the position occupied by the caret. |

 Retrieves any item containing at least five characters, the first two beginning with
 `sm`, followed by any character, and ending with `th`. This
 retrieves smith as well as smyth.

```
select invoices with name = "[sm^th]"
```

 Lists entity file items whose name attribute contains a string beginning with
 `i`, followed by any character, and ending with `m`.

```
list entity with name = "i^m"
```

 The example below lists entity items whose name attribute searches for values containing
 a string beginning with `a` and followed by two characters. Any two characters
 following the a meet the selection criteria:

```
list entity with name = "a^^"
```

---
Source: https://d3codex.com/access/string-searching/ - part of the D3Codex reference.
