analyse_pattern#

scikitplot.cleanprompt.analyse_pattern(source, flags=0)[source]#

Report the shapes in source that can backtrack catastrophically.

Parameters:
sourcestr

A regular expression, as written in a pack.

flagsint, default=0

The re flags the pattern is compiled with (case folding changes which characters overlap).

Returns:
tuple of PatternRisk

Empty when no known risky shape is present. A source this parser cannot model gives one not-analysed finding rather than nothing.

Parameters:
Return type:

tuple[PatternRisk, …]

Examples

>>> [risk.rule for risk in analyse_pattern(r"^(a+)+$")]
['nested-quantifier']
>>> analyse_pattern(r"\bEMP-\d{6}\b")
()
>>> analyse_pattern(r"(\w+,)+")
()