# Vocabulary/ecapdot

 x E. y Find Matches

Rank Infinity -- operates on x and y as a whole -- WHY IS THIS IMPORTANT?

Create a Boolean array indicating starting points in y of subarrays equal to x.

If x and y are character lists, this array marks the starts of the matching substrings in y

```   'co' E. 'cocoa'
1 0 1 0 0
```

### Common uses

1. Find the positions of all matching substrings

```   'co' I.@:E. 'cocoa'
0 2
```

2. To test whether a string x appears in the string y

```   'he' +./@:E. 'boustrophedonic'
1
```

3. Find positions in y that match subarray x

```   ]y =: 4 4 \$ 'abcdefghijklmnop'  NB. An array
abcd
efgh
ijkl
mnop
]x =: 2 2 \$ 'fgjk'              NB. Another array
fg
jk
x E. y                          NB. Do any subarrays of `y` match `x`?
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
```

1. The result of  x E. y has the same shape as y.

2. If x is an atom and y is a list, x is treated as a 1-atom list. Apart from that exception, x must have the same rank as y.

3. The result, at each atom of y, is 1 if a subarray of y starting at that position matches x.

4. If a position is too close to the end of y to have room for a subarray with the shape of x, that is simply recorded as a non-match.

```   y                  NB. A 2x2 array
abcd
efgh
ijkl
mnop
'bcd' E. y         NB. Rank of x must equal rank of y
|rank error
(,:'bcd') E. y     NB. Better
0 1 0 0
0 0 0 0
0 0 0 0
0 0 0 0
(,:'abcde') E. y   NB. x too big: no matches anywhere
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
```

5. x E. y uses tolerant comparison. Use  E.!.0 in place of  E. for exact comparison.

6. If x and y are character lists,  x E. y uses the Boyer-Moore algorithm.

### Known Bug

1. Warning: E. and the special forms u@:E. corrupt the J session if x and y are integer lists.

### Use These Combinations

Combinations using x E. y that have exceptionally good performance are shown in Searching and Matching Items: Fast List Operations (FLOs).