Regex for construction filenames, without breaking a sweat.
Test a pattern against your real filenames, or paste examples and let the tool derive a regex for you. Presets for ISO 19650, BS 1192, and Uniclass.
ISO 19650 · BS 1192 · Uniclass
| # | Token | Kind | Meaning |
|---|---|---|---|
| 1 | ^ | Anchor | Start anchor — the match must begin at the start of the filename. |
| 2 | [A-Z0-9]{2,6} | Char class | One character from: A–Z or 0–9, 2 to 6 times. |
| 3 | - | Literal | A literal hyphen — typically a segment separator. |
| 4 | [A-Z0-9]{2,6} | Char class | One character from: A–Z or 0–9, 2 to 6 times. |
| 5 | - | Literal | A literal hyphen — typically a segment separator. |
| 6 | [A-Z0-9]{1,2} | Char class | One character from: A–Z or 0–9, 1 to 2 times. |
| 7 | - | Literal | A literal hyphen — typically a segment separator. |
| 8 | (ZZ|XX|\d{2}) | Group | Capturing group — matches: one of ["ZZ", "XX", "\d{2}"] |
| 9 | - | Literal | A literal hyphen — typically a segment separator. |
| 10 | [A-Z0-9]{2,3} | Char class | One character from: A–Z or 0–9, 2 to 3 times. |
| 11 | - | Literal | A literal hyphen — typically a segment separator. |
| 12 | [A-Z] | Char class | One character from: A–Z. |
| 13 | - | Literal | A literal hyphen — typically a segment separator. |
| 14 | \d{4,6} | Char class | Any digit — 0 through 9, 4 to 6 times. |
| 15 | - | Literal | A literal hyphen — typically a segment separator. |
| 16 | [A-Z] | Char class | One character from: A–Z. |
| 17 | \d | Char class | Any digit — 0 through 9. |
| 18 | - | Literal | A literal hyphen — typically a segment separator. |
| 19 | [PC] | Char class | One character from: "P" or "C". |
| 20 | \d{1,3} | Char class | Any digit — 0 through 9, 1 to 3 times. |
| 21 | (\.[A-Za-z0-9]+)? | Group | Capturing group — matches: "\.[A-Za-z0-9]+", optional (zero or one). |
| 22 | $ | Anchor | End anchor — the match must reach the end of the filename. |
Results
2 / 3 match- ABC-XYZ-01-00-DR-A-0001-S2-P01.pdf
- ABC-XYZ-01-01-DR-S-0002-S2-P01.pdf
- WRONG-FILENAME.pdf
How regex works — a primer for construction filenames
You don't need to be a regex wizard to define a useful naming rule. Five or six primitives cover 95% of AEC filename conventions — most of them are in the cheat-sheet tab above the sample box.
Named capture groups
When you use (?<name>pattern) instead of a plain (pattern), you can pull the matched value back out by name.
That's how the full Foreman product turns a single naming rule into columns in a searchable register — every named group becomes a queryable attribute.
Common traps
- Forgetting anchors. Without
^and$,[A-Z]{3}happily matches "ABC" inside "BADABCX". Anchor everything. - Case.
[A-Z]doesn't match lowercase. If case doesn't matter in your convention, either use[A-Za-z]or enable case-insensitive mode on your engine. - The file extension. Some CDEs display filenames with extensions stripped. Make the extension optional:
(\.[A-Za-z0-9]+)?$. - Greedy vs lazy.
.+grabs as much as possible. For "one of several short things", use.+?or a specific char class.
Want AI help? The full Foreman product has an AI regex builder that writes patterns from a natural-language description — useful when your convention has conditional rules (e.g. "if discipline = ST then…") that a pure pattern can't express. See the QA feature.
Next step: promote this pattern into Foreman rule sets, assign it per folder, and combine filename regex with metadata checks in Forma (ACC) for end-to-end compliance. Get started free.
Free tools
More tools you might like
Time-to-Value Calculator
Estimate yearly hours and cost saved by automating QA and admin checks.
Mini Project Matrix Wizard
Design a folder matrix for your project in under 60 seconds. Download a structure anyone can follow.
ISO 19650 Filename Validator
Validate one filename or a whole register. See segment-level failures and export clean results.
Regex that works on your laptop — now run it on every project
Foreman stores rule sets per tenant, assigns them per folder, and runs them on every upload, alongside metadata checks. Plus AI regex generation, OCR on title blocks, and branded reports.
14-day trial · Full access · No card on file· See the full feature →