GGlobHaven
Workflows

Coding workflows · Bounded wildcard matching

03
Built around your work

A concrete starting point

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.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Bounded wildcard matching

A concrete starting point
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.

AI coding workspace

Your next change starts here.

Get the Windows app ↗