skbio.sequence.Sequence.find_with_regex#
- Sequence.find_with_regex(regex, ignore=None)[source]#
Generate slices for patterns matched by a regular expression.
- Parameters:
- regexstr or regular expression object
String to be compiled into a regular expression, or a pre- compiled regular expression object (e.g., from calling
re.compile
).- ignore1D array_like (bool) or iterable (slices or ints), optional
Indicate the positions to ignore when matching.
- Yields:
- slice
Location where the regular expression matched.
Examples
>>> from skbio import Sequence >>> s = Sequence('AATATACCGGTTATAA') >>> for match in s.find_with_regex('(TATA+)'): ... match ... str(s[match]) slice(2, 6, None) 'TATA' slice(11, 16, None) 'TATAA'