Quick overview

Find some simple instructions below


First, obtain at least Python 3.6 and virtualenv if you do not already have them. Using a virtual environment is strongly recommended, since it will help you to avoid clutter in your system-wide libraries. Once the requirements are met, you can use pip:

pip install trrex


Here are some quick examples of what you can do with trrex.

To begin, import re and trrex:

In [1]: import re

In [2]: import trrex as tx

Search for any keyword

You can search for keywords by using re.search:

In [3]: keywords = tx.make(["baby", "bad", "bat"])

In [4]: match = re.search(keywords, "I saw a bat")

In [5]: match
Out[5]: <_sre.SRE_Match object; span=(8, 11), match='bat'>

In this case we find bat the only keyword appearing in the text.

Replace a keyword

You can replace a keyword by using re.sub:

In [6]: keywords = tx.make(["baby", "bad", "bat"])

In [7]: replaced = re.sub(keywords, "bowl", "The bat is round")

In [8]: replaced
Out[8]: 'The bowl is round'