# dataiter.regex

The `regex` module contains vectorized versions of regular expression matching
operations, similar to `numpy.strings` for string operations. This is a
convenience wrapper around Python’s standard library `re` module, not any
efficient reimplementation.

[`findall()`](#dataiter.regex.findall)
[`fullmatch()`](#dataiter.regex.fullmatch)
[`match()`](#dataiter.regex.match)
[`search()`](#dataiter.regex.search)
[`split()`](#dataiter.regex.split)
[`sub()`](#dataiter.regex.sub)
[`subn()`](#dataiter.regex.subn)

<a id="module-dataiter.regex"></a>

### dataiter.regex.findall(pattern, string, flags=0)

Return a list of matches of pattern in string.

[https://docs.python.org/3/library/re.html#re.findall](https://docs.python.org/3/library/re.html#re.findall)

```pycon
>>> x = di.Vector(["asdf", "1234"])
>>> regex.findall(r"[a-z]", x)
[ ['a', 's', 'd', 'f'] [] ] object
```

### dataiter.regex.fullmatch(pattern, string, flags=0)

Return a `re.Match` object or `None`.

[https://docs.python.org/3/library/re.html#re.fullmatch](https://docs.python.org/3/library/re.html#re.fullmatch)

```pycon
>>> x = di.Vector(["asdf", "1234"])
>>> regex.fullmatch(r"[a-z]+", x)
[ <re.Match object; span=(0, 4), match='asdf'>
                                          None ] object
```

### dataiter.regex.match(pattern, string, flags=0)

Return a `re.Match` object or `None`.

[https://docs.python.org/3/library/re.html#re.match](https://docs.python.org/3/library/re.html#re.match)

```pycon
>>> x = di.Vector(["asdf", "1234"])
>>> regex.match(r"[a-z]", x)
[ <re.Match object; span=(0, 1), match='a'>
                                       None ] object
```

### dataiter.regex.search(pattern, string, flags=0)

Return a `re.Match` object or `None`.

[https://docs.python.org/3/library/re.html#re.search](https://docs.python.org/3/library/re.html#re.search)

```pycon
>>> x = di.Vector(["asdf", "1234"])
>>> regex.search(r"[a-z]", x)
[ <re.Match object; span=(0, 1), match='a'>
                                       None ] object
```

### dataiter.regex.split(pattern, string, maxsplit=0, flags=0)

Return a list of string split by pattern.

[https://docs.python.org/3/library/re.html#re.split](https://docs.python.org/3/library/re.html#re.split)

```pycon
>>> x = di.Vector(["one two three", "four"])
>>> regex.split(r" +", x)
[ ['one', 'two', 'three'] ['four'] ] object
```

### dataiter.regex.sub(pattern, repl, string, count=0, flags=0)

Return string with instances of pattern replaced with repl.

[https://docs.python.org/3/library/re.html#re.sub](https://docs.python.org/3/library/re.html#re.sub)

```pycon
>>> x = di.Vector(["great", "fantastic"])
>>> regex.sub(r"$", r"!", x)
[ "great!" "fantastic!" ] string
```

### dataiter.regex.subn(pattern, repl, string, count=0, flags=0)

Return string, count of instances of pattern replaced with repl.

[https://docs.python.org/3/library/re.html#re.subn](https://docs.python.org/3/library/re.html#re.subn)

```pycon
>>> x = di.Vector(["great", "fantastic"])
>>> regex.subn(r"$", r"!", x)
[ ('great!', 1) ('fantastic!', 1) ] object
```
