API Reference#

The API of trrex is composed of a single function

trrex.make(words: Sequence[str], prefix: str = '\\b', suffix: str = '\\b')#

Create a string that represents a regular expression object from a set of strings

Parameters:
wordsSequence[str]

Sequence or set of strings to be made into a regex

prefixstr, optional

Left delimiter for pattern

suffixstr, optional

Right delimiter for pattern

Returns:
String

A string representing a regular expression pattern

Examples

>>> import re
>>> import trrex as tx
>>> pattern = tx.make(["baby", "bat", "bad"])
>>> re.findall(pattern, "The baby was scared by the bad bat.")
['baby', 'bad', 'bat']