FREE PRACTICAL AI LEARNING · BUILD AT YOUR OWN PACEOPEN MATERIALS · YOUR WORK TO KEEP
Open PracticePRACTICAL AI ENGINEERING
FREE PRACTICAL AI EXERCISE / 42

Ask for a regex, then attack its assumptions

Turn a fuzzy matching request into explicit positive and negative test cases.

45 minutes estimated—not learner-validated. Original learning materials are free; optional external AI access may require an account, credits or payment.

Start the editable activity →

No account needed to begin. Explicit account saving and editable offline export are available in the workspace.

New here? Try the three-activity starter ↗
Ask for a regex, then attack its assumptions — original AI-generated editorial illustration

Why this matters

A regex for a limited filter is not a complete email validator. Decide whether a hyphen must occur in the local part or anywhere in the address, whether subdomains count and whether matching is case-insensitive. The activity test runner uses a short-lived worker and synthetic strings, not a production data scan.

Before you start

Materials are free. External tools may require an adult account, credits, regional eligibility or a paid plan. Check current terms before using them. Do not paste passwords, API keys, private messages or other people’s personal data. No model runs locally or downloads automatically on this platform.

Your illustrated field guide

Specify: Define what counts as a match; Generate: Name engine and flags; Run: Compare positive and negative cases; Limit: Document excluded valid formats

Conceptual illustration, not a provider screenshot. Artwork is AI-generated; instructional labels are authored text.

Start with fictional input

Specification: local part must contain a hyphen; domain is one simple label followed by .edu; no spaces; case-insensitive. Match: first-last@example.edu; A-B@COLLEGE.EDU. Reject: firstlast@example.edu; first-last@example.com; firstlast@my-college.edu; first-last@dept.example.edu.

Copy and adapt this prompt

Propose a bounded JavaScript regex for exactly the stated simplified filter, not RFC-complete email validation. Explain the anchors, local-part hyphen rule, simple domain and case-insensitive flag. Provide results for all supplied tests and at least two edge cases. Do not claim it verifies delivery or institutional status.

Worked reference—not proof of correctness

One limited pattern: ^[A-Z0-9._+]*-[A-Z0-9._+-]*@[A-Z0-9]+(?:-[A-Z0-9]+)*\.edu$ with i flag. Check its actual behaviour; “a-b@example.edu” is a match, while a hyphen only in the domain is insufficient. The simplified grammar intentionally excludes some valid real addresses.

Five practical steps

  1. Define the policy

    Write the exact location of the hyphen and domain/subdomain rules before asking for syntax.

  2. Get a draft pattern

    Request the target engine and flags; do not copy syntax intended for a different language.

  3. Run the fixture

    Use the bounded test tool and compare actual results with the reference list.

  4. Try edge cases

    Add spaces, an empty local part and uppercase letters; keep false positives and negatives visible.

  5. State the scope

    Label the filter as a toy policy check, not email validation or proof of eligibility.

Test your result

  • All six supplied strings have recorded expected and observed results.
  • A hyphen only in the domain does not satisfy the local-part requirement.
  • The report names JavaScript/flags and clearly limits the simplified grammar.

Mistakes to watch for

  • Calling a matching string a deliverable or institution-verified email address.
  • Using an unbounded pattern or huge input without a timeout.

Offline / no-key route

Mark expected matches by hand and explain the policy without executing a pattern.

Reflect

Which valid real-world address might your deliberately simplified filter reject?

Keep your notes, tests and self-review →

Self-reported practice is not independent assessment or a qualification. Browse all 50 guides · Choose a tool