RelayVano

← All postcards

Checking Order IDs Before Friday’s Release

Field trips EN

Your team is shipping an order lookup form on Friday. Every order ID should look like ORD-004219, and anything else should produce a helpful error. An AI assistant can suggest a regular expression for that check in seconds. The important part is telling it exactly what counts as valid—and checking that its answer follows those rules.

The order ID rule behind the regular expression

A regular expression, often shortened to regex, is a compact pattern for matching text. Instead of listing every valid order ID, you describe the shape they all share: the letters ORD, a hyphen, and six digits.

Regex is useful for simple formats, searches, and text extraction. It does not tell you whether an order actually exists. That requires a database lookup. Keeping those jobs separate makes both your prompt and your application easier to understand.

Before asking an AI for a pattern, settle these details:

  • Must the letters be uppercase?
  • Are leading zeros allowed?
  • Does “digit” mean only the characters 0 through 9?
  • Should surrounding spaces be rejected or removed?
  • Must the whole input match, or are you searching inside a longer message?

These are product decisions, not details the model should invent.

A prompt that specifies Python and exact matching

Regular expressions have different dialects. A pattern written for JavaScript may not behave the same way in Python or a database. Name the environment and the matching operation in your prompt.

For the order form, send this:

“Write a regular expression for Python 3. I will use re.fullmatch to validate the entire input string. Valid order IDs start with the exact uppercase text ORD-, followed by exactly six ASCII digits, 0 through 9. Leading zeros are allowed. Reject spaces, trailing newlines, lowercase letters, and extra characters. Do not trim or otherwise change the input. Return the raw pattern without slash delimiters, explain each part, and provide valid and invalid test cases.”

A suitable answer is ORD-[0-9]{6}. The ORD- portion matches those exact characters. The [0-9] portion matches one ASCII digit. The {6} portion requires six repetitions.

Notice that the pattern does not need start and end markers here: Python’s re.fullmatch already requires the whole string to match. Also, [0-9] is deliberate. In Python, the shorthand \d can match Unicode decimal digits beyond the ASCII characters your rule allows.

Independent tests for the order form

Do not treat the assistant’s explanation as proof. Write your own expected results before running the pattern, then compare them with the actual results.

  • Accept ORD-004219, ORD-000000, and ORD-999999.
  • Reject ord-004219 because the prefix is lowercase.
  • Reject ORD-04219 and ORD-0004219 because the digit count is wrong.
  • Reject ORD-00421A because a letter appears in the numeric portion.
  • Reject ORD-123456 because those are not ASCII digits.
  • Reject a leading space, a trailing space, or a newline after an otherwise valid ID.
  • Reject an empty string and text such as “Order: ORD-004219”.

After importing Python’s re module, the validation expression is re.fullmatch(r"ORD-[0-9]{6}", value) is not None. Run that check against every test input. For newline tests, make sure the input contains an actual newline character, not merely the printed characters backslash and n.

Reviewing revisions without changing the rules

If a test fails, send the assistant the pattern, the exact input, your expected result, and the actual result. Ask for the smallest correction that preserves the other rules. Then rerun every test, not just the failing one.

Use an online regex tester only if it supports your dialect and matching behavior. The final check should run in the same environment as your application. For complicated patterns, also test long invalid inputs: some expressions can become unexpectedly slow.

A repeatable AI-assisted validation workflow

For this prompt-and-test workflow, RelayVano is a practical pay-as-you-go option for accessing AI models through an OpenAI-compatible SDK. Sign up when you want to try it with your own validation tasks.

Keep the prompt, pattern, and tests together in your project. When the order format changes, update the written rules first. Let AI propose the expression; let executable tests decide whether it is ready for Friday’s release.

More postcards from this route