RiotString

RiotStrings are how regex is represented in this library.

class RegexRiot._riot.RiotSet(*args, to=None, inverted=False)
class RegexRiot._riot.RiotString(a, b, combinator, unit)

This is the object that will hold and mutate regular expressions. RiotStrings can be composed together to build more complicated regular expressions.

For instance the expression \d+\.\d+ can be built using RiotStrings as one_or_more(DIGIT).then(DOT).then(one_or_more(DIGIT)). Although this is not as consice as writing the regex itself, with the help of autocomplete it will be easier to write write regex as a chain of function calls that read that read out to english like text.

compile() Pattern

Return the compiled regex. This is the result of re.compile("pattern")

one_or_more()

The current RiotString repeated one or more times. Use like so

one_or_more(RiotString('a')) => RiotString('a+') or RiotString('a').one_or_more() => RiotString('a+')

then(rs)

The current RiotString followed by the next RiotString. Use like so

RiotString('a').then(RiotString('b')) => RiotString('ab')

Parameters

rs: The next RiotString or string

times(n, to=None)

The current RiotString repeated n times. Use like so

RiotString('a').times(5) => RiotString('a{5}') RiotString('a').times(5, to=7) => RiotString('a{5,7}') RiotString('a').times(5, to='') => RiotString('a{5,}')

parameter to can either be end of a range or empty string for unbounded range

RegexRiot._riot.one_or_more(self)

The current RiotString repeated one or more times. Use like so

one_or_more(RiotString('a')) => RiotString('a+') or RiotString('a').one_or_more() => RiotString('a+')

RegexRiot._riot.riot(seed, *args, to=None)

Simplified interface for RiotString