backtracking.match_word_pattern

Functions

match_word_pattern(→ bool)

Determine if a given pattern matches a string using backtracking.

Module Contents

backtracking.match_word_pattern.match_word_pattern(pattern: str, input_string: str) bool

Determine if a given pattern matches a string using backtracking.

pattern: The pattern to match. input_string: The string to match against the pattern. return: True if the pattern matches the string, False otherwise.

>>> match_word_pattern("aba", "GraphTreesGraph")
True
>>> match_word_pattern("xyx", "PythonRubyPython")
True
>>> match_word_pattern("GG", "PythonJavaPython")
False