aeidon.Finder

Source: aeidon/finder.py

Anchestors: builtins.object

class aeidon.Finder

String and regular expression finder and replacer.

Finder.ignore_case

True to ignore case when finding matches

Finder.match

Regular expression object for the latest match of pattern

Finder.match_span

Tuple of start and end position for match

Finder.pattern

String or regular expression object to find

Finder.pos

Current offset from the beginning of the text

Finder.replacement

Plain- or regular expression replacement string

Finder.text

Target text to find matches of pattern in

Methods

Finder.__init__()

Initialize a Finder instance.

Finder.next()

Find the next match of pattern.

Raise StopIteration if no next match found. Return tuple of match start, end position.

Finder.previous()

Find the previous match of pattern.

Raise StopIteration if no previous match found. Return tuple of match start, end position.

Finder.replace(next=True)

Replace the current match of pattern.

next should be True to finish at end of match, False for beginning. Raise re.error if bad replacement.

Finder.replace_all()

Replace all occurences of pattern.

Raise re.error if bad replacement. Return the amount of substitutions made.

Finder.set_regex(pattern, flags=24)

Set and use regular expression as pattern.

The default value for flags is DOTALL and MULTILINE. IGNORECASE is automatically added to flags if ignore_case is True.

Raise re.error if bad pattern.

Finder.set_text(text)

Set the target text to search in and reset position.