Open the context
Choose the project folder and name the files or behavior involved.
Match a whole string with question-mark and star wildcards using at most 256 Unicode code points per input. Check empty strings, consecutive stars and emoji, rejecting bracket or backslash syntax rather than interpreting unsupported pattern rules.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def wildcard(text, pattern):
if not isinstance(text, str) or not isinstance(pattern, str):
raise ValueError("text.required")
if len(text) > 256 or len(pattern) > 256:
raise ValueError("length.cap")
if any(ord(c) in (91, 93, 92) for c in pattern):
raise ValueError("syntax.unsupported")
previous = [True] + [False] * len(pattern)
for j, token in enumerate(pattern, 1):
previous[j] = token == "*" and previous[j - 1]
for char in text:
current = [False] * (len(pattern) + 1)
for j, token in enumerate(pattern, 1):
current[j] = (current[j - 1] or previous[j]) if token == "*" else (
previous[j - 1] and (token == "?" or token == char))
previous = current
return previous[-1]The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.