Regular expressions for testers
Read and write small patterns to check text, pull dates and users out of a log, and test the pattern itself.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a stencil. Lay a plastic stencil over a blank page of paper. Only the shapes that fit the holes show through. A stencil for a phone number has holes for digits and gaps for spaces.
Daily List is a to-do list app. Lily types an email address into the sign-up form. The app must decide if it looks like an email. It uses a short pattern, like a stencil, to check the shape.
The pattern says: some letters, then an at sign, then more letters. Then comes a dot and a few more letters. The address lily@example.com fits. The address lily@example has no dot and no ending, so it does not.
That pattern is a . Testers meet it in forms, in logs and in checks.
The picture has limits. A stencil is fixed and cheap. A pattern can be wrong in sneaky ways, and a bad one can even freeze the app.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PLAIN WORDS · 1 in this section
- stencil
- a cut-out sheet used to paint the same shape
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Describing the shape of text with a small pattern, then testing what it wrongly keeps out or lets in.
- Describe the shape
- Fix the edges
- Keep the parts you need
- Test good and bad input
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The stencil | The pattern |
| The holes | The pieces, such as digit or letter |
| The edge of the page | Start and end anchors |
| A cut-out you keep | A capture group |
WHERE THIS PICTURE STOPS
- A stencil is cut once. A pattern needs tests with good and bad examples.
- A stencil cannot freeze. A pattern can get very slow.
- A stencil shows only shape, not meaning, and so does a pattern.
HOOK
Shape, edges, keep.
REMEMBER IT THIS WAY
A chunk: a long list grouped so it is easier to hold.
Test a pattern with a pair: lily@example.com should fit and lily@example should not. If both give the same answer, the pattern needs work.
| In the trick | What it stands for |
|---|---|
| The pair | Good and bad examples |
| The edges | Start and end anchors |
| The keep | A capture group |
TELL A FRIEND
A stencil lets through only what fits its holes. A pattern lets through only text with the right shape.
OFTEN MIXED UP WITH Programming basics for testers (read, don't build). The programming lesson reads code. This lesson reads and writes patterns that code uses.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
Regular expressions: groups and backreferences (Mozilla developer docs) ↗ — Mozilla · Capturing groups keep extra submatch information; quantifiers are greedy by default and a question mark after a quantifier makes them non-greedy (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Regular Expression HOWTO (Python documentation) ↗ — Python · A greedy pattern can make the engine give back characters one at a time and backtrack until the rest of the pattern matches (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Internet Message Format (Request for Comments 5322) ↗ — IETF · An address is a local part, an at sign and a domain; the local part may be a dot-atom or a quoted string (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
ISTQB Certified Tester Foundation Level Syllabus v4.0.1 ↗ — International Software Testing Qualifications Board · Tool support and test data chapters: the syllabus asks testers to think about the data they use (confirmed against the syllabus, read in full text from a mirror copy of the publisher PDF, v4.0.1, 15 September 2024)
v4.0.1 is dated 15 September 2024 and is a list of corrections to v4.0 (21 April 2023) that reworded six learning objectives — not a cosmetic reissue. 78 pages.
Two traps this entry exists to stop. v4.0.2 is the German edition (1 March 2025, 94 pages), so sorting by version number reaches the wrong document. And the widely-repeated per-chapter question allocation "8 / 5 / 4 / 11 / 9 / 3" is wrong: it is 8 / 6 / 4 / 11 / 9 / 2, derived from three official sample-exam answer keys and confirmed against the Exam Structure Tables.
The single most consequential detail for a question bank: white-box coverage — statement and branch — is K2 "Explain", not K3 "Apply" (FL-4.3.1, FL-4.3.2, FL-4.3.3), and MC/DC, path and condition coverage are declared out of scope in §4.3. A question asking a candidate to compute branch coverage is testing something this syllabus does not.
Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.
Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.
Read from two independent PDF-to-markdown conversions mirrored on raw.githubusercontent.com. They are treated as faithful because they were produced by unrelated parties with different tooling, agree on the full 64-item objective set including wording, and reproduce the same internal inconsistency present in the source PDF. Chapter 1 reads "testware that supports" where Appendix B reads "that support". A conversion artefact does not replicate across two toolchains.
The licence permits attributed non-commercial extracts and use as the basis for articles. Whether a site that sells a pass may rely on that is an owner's decision, not this entry's.
7 November 2026 review: actual publisher PDF 4.0.1, 15 September 2024, 78 pages, front matter/copyright and relevant numbered operative sections 0.5–0.10 and chapters 1–6 compared with CTFLpractice lessons. Earlier mirror/search descriptions are historical access records. TheK2 white-box objectives require explanation; the source does not justify a categorical ban on small numeric illustrations that support explanation. Later Exam Rules 1.2§4.1.4 usesK2 for keyword definitions, while syllabus§0.5 usesK1; keep dated scopes distinct. No copied questions or figure assets.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.