Provide a minimal pattern syntax for filtering lists of objects by their labels.
The syntax is intentionally simpler than regular expressions. It is designed for common label-search operations such as:
- contains
- starts with
- ends with
- exact match
- wildcard matching
- character-set matching
- OR matching
- case-sensitivity options
- literal use of reserved characters
The language was set four goals: easy to learn, easy to type, easy to view, and complete enough for most needs.
These four are the tie-breaker for every future proposal. A syntax that serves one of them at another's expense is not obviously an improvement, and this section is where that argument gets settled. Each goal is recorded with what serves it and what strains it, because a goal with no recorded cost cannot be used to decide anything.
Served by the default. A plain word is a case-insensitive contains, so the most common search costs no syntax at all and nothing has to be learned before the language is useful. Seven reserved characters; no parentheses beyond the one flat group, no quantifiers, no lookahead, no capture, no flags. The whole language fits in a table of a dozen lines.
It is strained by any character that means two things. A rule a parser can apply but a person cannot apply at a glance costs this goal outright, however defensible it is on every other count. That is the test a proposal has to pass: not can this be specified, but can it be read.
Served by the zero-syntax default, one-character anchors, and one-character wildcards. Nothing
common requires a modifier key except * and |.
Strained by the backtick's position on a keyboard. It is a dead key on several European layouts (needing a following space), two or three taps deep on phone keyboards, and in some hosts it opens code formatting instead of typing. That falls on the second most common operation in the language after contains. Nothing in the syntax can fix it; a host that embeds this filter can, with a control that inserts the anchors.
And by the cost of a group. *.||md|txt|| is longer than *.md|*.txt. A group pays for itself
only when the shared part is long, which is exactly when it is worth having, so this is a fair trade
rather than a defect, but it means a group is not the shorter spelling, only the one that does not
repeat itself.
Served by short patterns, no escaping thicket in the common case, and alternatives that read left to right with no precedence to remember beyond the table in §11.
It is strained by runs of the same delimiter. `#[0-9a-f][0-9a-f][0-9a-f]` is dense, and
a set spelling where the opening and closing characters looked alike would be a picket fence the eye
cannot count. Every delimiter in this language says which end it is, and that is deliberate.
Served: contains, starts, ends, exact, wildcard, one-of-characters, ranges, alternation, grouping, case control, escapes. Between them these answer the large majority of list filtering.
Negation and word boundaries are covered by \-\ and \b\, neither of which costs a reserved
character: the option section is already the place for anything that governs the whole pattern.
What remains, in order of how often it would actually be missed:
- repetition,
[0-9]four times over is how a four-digit year is written - include-except,
\-\is an exclusion filter, so apple but not test still needs two filters, or an AND this language deliberately does not have
Deliberately out of scope, and not gaps: numeric or date comparison, field-scoped terms
(name:foo), fuzzy or ranked matching, and anything requiring a regex engine's machinery. A label
filter that grew those would stop being learnable in an afternoon, which is the first goal.
Seven characters have special meaning:
* | & ` \ [ ]
All other characters are treated as ordinary literal characters.
*is a wildcard (§4).|separates alternatives, and||opens and closes a group (§8).&separates items, every one of which must match (§8).`is an anchor, and nothing else: the first character of an alternative, the last, or an error (§5).\escapes a reserved character, and a\…\section at the very start of a pattern carries its options (§9, §10).[and]delimit a character set (§6).
A pattern with no anchors or wildcards performs a case-insensitive substring/contains match.
apple
matches:
apple
Apple
APPLE
Green Apple
pineAPPLE
Case sensitivity can be explicitly changed with an option.
The asterisk * matches zero or more arbitrary characters.
apple*pie
matches:
applepie
apple pie
apple-and-pear-pie
but not:
apple
pie
banana pie
Wildcards may appear anywhere in a pattern.
A backtick ` at the beginning or end of a pattern acts as an anchor.
`apple
means:
the label must start with
apple.
Matches:
apple
apple pie
apples
Does not match:
green apple
pineapple
apple`
means:
the label must end with
apple.
Matches:
apple
green apple
pineapple
Does not match:
apple pie
apples
`apple`
means:
the label must equal
appleexactly.
Because matching is case-insensitive by default, this also matches Apple, APPLE, etc.
Case-sensitive exact matching is:
\c\`apple`
A pair of brackets defines a single-character set.
[123]
matches exactly one character from 1, 2, 3. So:
foo[123]bar
matches foo1bar, foo2bar and foo3bar.
A character set always consumes exactly one character.
A set may contain ranges:
[0-9] one digit
[a-z] one lowercase letter
[A-Za-z] one ASCII letter
[0-9A-F] one hexadecimal character
In both modes, including the default case-insensitive one. A set is the one construct that can say
either case explicitly, by writing [A-Za-z], while nothing else could say this case only. If a set
folded with case, [A-Z], [a-z] and [A-Za-z] would be three spellings of one thing, and there would
be no way to ask for one case without hardening every literal in the pattern.
A literal still folds: apple matches APPLE by default, and \c\ (§10) turns that off. \c\
governs literals only.
- An empty set
[]is refused. It could never match, and a pattern that silently matches nothing is the outcome this language exists to avoid. - An unclosed
[and an unmatched]are refused, naming the escape that writes a literal one. - A literal bracket is
\[or\]. - An escaped dash is a literal dash:
[a\-z]is the three charactersa,-,z, where[a-z]is a range. A leading or trailing dash is a literal without escaping.
A set needs nothing special next to an anchor. A backtick is an anchor and a bracket delimits a set, so the two cannot be confused and there is no doubling, no counting and no lookahead:
`[123]bar starts with one of 1, 2, 3, then bar
bar[456]` bar, then one of 4, 5, 6, at the end
`[123]bar[456]` both
foo[123]bar anywhere in the pattern, including the very start
This section exists because it once did not hold. While a single character both delimited sets and anchored the pattern, every one of these spellings was ambiguous and needed a rule to resolve it. The rule is now that there is no ambiguity.
The vertical bar | separates alternative patterns.
apple|banana
matches a label if it contains either:
apple
or:
banana
Examples:
`apple|`banana
means:
starts with
appleOR starts withbanana.
apple`|banana`
means:
ends with
appleOR ends withbanana.
Each |-separated alternative is evaluated independently.
A pattern that ends in one unescaped & or | is read as if that last character were absent.
apple& means apple, apple| means apple, and apple&pie| means apple&pie.
A filter is typed one character at a time, and every a&b and a|b passes through a& and a| on
the way. Without this rule those keystrokes answered the wrong question: a& was refused, which shows
every label (§14), and a| held an empty alternative, which matches every label too. Either way the
list jumped back to everything until the next character arrived.
- Only one character is dropped.
a&&is still an empty item between two&, and is refused. - Only at the end. A leading
&aand a doubleda&&bare refused as before. - An escaped operator is a literal and is kept.
a\&containsa&;a\|containsa|. Ina\\&the backslash is escaped, so the&is not, and it is dropped. - A
|counts only as a run of one. The||that closes a group is not a trailing operator, and a run of three is refused as always. - It is applied before anything else, so under negation
\-\apple|means\-\apple. Kept as an empty alternative, the bar would have negated a pattern that matches everything and hidden every row.
A group lets a shared part be written once instead of once per alternative:
*.||md|txt|| the same as *.md|*.txt
`||a|b||` exactly a, or exactly b
An anchor outside a group reaches every branch of it, which is the reading that plain alternation cannot give.
Rules.
- A group does not nest. A
||inside a group is an error, not a second level. - Three or more
|in a row is refused rather than guessed at. This one rule is what keeps||decidable, and it is also what makes an empty group and an empty branch unwritable. - An unclosed group is refused, naming the spelling of a literal bar.
- A literal bar is
\|. - A group is expanded into plain alternatives before matching, so nothing downstream has to know it was written as one. The expansion is bounded: a pattern whose groups multiply out past 64 alternatives is refused, with the count named, rather than expanded.
An anchor binds to the alternative it is written in, so `a|b` means starts with a OR ends with
b. It reads to everyone as exactly a or exactly b, because the two anchors sit at the outer
edges and look like they wrap the alternation.
It parses cleanly and answers a different question, which is the one failure this language refuses to
allow. Write `||a|b||` for the reading it looks like.
The ampersand & separates items. A label matches the pattern when it matches every item.
apple&\-\test
means:
contains
appleAND does not containtest.
An item is a whole pattern, not a fragment of one. It carries its own option section, its own
alternatives, its own group and its own anchors, and it is matched on its own. That is the whole of the
semantics, and it is what makes include, except writable: the exclusion is an ordinary \-\ pattern
that happens to be one item among several.
rust&2026 contains rust AND contains 2026, in either order
a&b&c all three, in any order
`src&md` starts with src AND ends with md
[0-9]&\-\draft contains a digit AND does not contain draft
& is unordered where * is ordered. a*b requires a before b; a&b asks only that both are
present. Written with alternation instead, both in any order is a*b|b*a, and for three terms it is
six alternatives, for four twenty-four. That blowup is the reason this operator exists.
Options do not span items. Each item reads its own section, so \c\App&\-\Test is a
case-sensitive App and a case-insensitive Test. To harden both, write both: \c\App&\c-\Test.
The repetition is the price of an item being a whole pattern, and it is visible rather than silent.
Rules.
- A literal ampersand is
\&. It is the seventh reserved character, and the escape has always been available:\takes any non-alphanumeric (§9). - An empty item is refused.
&aanda&&bare errors rather than and everything, which is what an empty pattern would mean. - A trailing
&is dropped instead, soa&reads asa. That is the state a pattern passes through while it is being typed, and refusing it flashed the list back to every row betweena&anda&b. Only one is dropped:a&&still leaves an empty item between two&. See §8, A trailing operator is not there. &cannot appear inside a||…||group. Items are split before groups expand, so a&in a group has no item to belong to:||a&b||would have to expand to something likea&bc, which is not a reading of anything. A literal ampersand is\&.- An item that cannot be read makes the whole pattern unreadable, so it matches every label and carries the reason (§14). An unreadable item is never treated as did not match: that would hide rows for a reason nobody can see, through the one operator that can turn a typo into an empty list.
- Items do not multiply. Each is matched independently and the verdicts are combined, so the
64-alternative cap of §8 applies within an item and nothing about
&can reach it.
The two operators mix freely, and & is the weaker one:
a|b&c (a OR b) AND c
||a|b||&c the same thing, bracketed
a&b|c a AND (b OR c)
This is the opposite of the C family, where && binds tighter than ||, and that is a real cost
rather than a detail: a reader arriving from any of those languages will read a|b&c as
a OR (b AND c) until told otherwise. It is written down here, in §11's table and in the
implementations, because it is the one rule in this language that a reader's prior knowledge argues
against.
What it buys is that an item is a whole pattern with nothing above it but conjunction. Alternation,
anchors, sets and options all live inside an item and compose exactly as they did before & existed,
and a|b&c needs no brackets to mean the common thing: either of these two, and also that. The
bracketed spelling ||a|b||&c remains available and means the same, so the grouping can always be
made explicit where a pattern is long enough to want it.
The alternative considered was refusing the unbracketed mix outright, in the way `a|b` is
refused. That trades a reading a reader arrives with for a refusal a reader also has to learn, and a
refusal teaches nothing about what the language does.
One rule, and it is the one above:
- One trailing operator is dropped, then the pattern splits on unescaped
&into items.&is the loosest operator in the language. - Within an item, the option section, if present, is read once from the start of that item (§10).
||…||groups expand into alternatives.- The item splits on the remaining
|. - Each alternative is matched independently: its anchors, wildcards, sets and literals apply to it and to nothing else.
A label passes when every item matches, and an item matches when any of its alternatives does.
||…|| is the only bracket in the language and it brackets alternatives. There are no parentheses, and
with & the loosest operator there is nothing for them to do that the group does not already do.
The backslash \ removes the special meaning of the following character when used within the pattern.
\*
matches a literal *.
\|
matches a literal |.
\`
matches a literal backtick.
\\
matches a literal backslash.
Examples:
version\*2
matches:
version*2
foo\|bar
matches:
foo|bar
foo\`bar
matches:
foo`bar
An escaped character does not participate in pattern syntax.
A backslash may escape any character that is not an ASCII letter or digit. So \*, \|, \`,
\\, \[, \], \., \-, \ , and equally \é, \« and \🙂: punctuation, spaces, unicode and
emoji are all escapable, and escaping a character that was never special simply yields that character.
Escaping a letter or a digit is refused. \d, \n, \w and \s mean a character class in a
regular expression and mean nothing here, so reading \n as the letter n would quietly give a pattern
a second meaning. The refusal names the option syntax, because \c is almost always a mistyped \c\.
This holds in the pattern body and inside a set body alike.
A trailing lone backslash is what a pattern looks like while it is being typed, so it is a literal backslash rather than an error.
Options are introduced by a leading backslash and terminated by a second backslash.
General form:
\options\pattern
The second \ marks the end of the option section. Everything following it is parsed as the normal pattern syntax.
The section is read once, from the start of its item, before that item is split on |. So an
option applies to every alternative of the item it opens, and a section written at the start of an
alternative is refused rather than read as an option or as the literals it is made of; see An option
section cannot open an alternative below.
A pattern with no & is a single item, so for every pattern written without one this is the rule it
has always been: read once, from the very start. What & adds is that options do not span items
(§8), and \c\App&\-\Test therefore holds one case-sensitive item and one case-insensitive one.
Matching is case-insensitive by default.
The c option enables case-sensitive matching:
\c\apple
means:
case-sensitive, contains
apple.
Without the option:
apple
means:
case-insensitive, contains
apple.
Options apply to the entire pattern.
\c\`apple
means:
case-sensitive, starts with
apple.
\c\apple`
means:
case-sensitive, ends with
apple.
\c\`apple`
means:
case-sensitive, exactly
apple.
\c\`[A-Z]foo
means:
case-sensitive, starts with one uppercase letter, followed by
foo.
The option prefix ends at the second backslash; everything after it uses the normal pattern syntax. A set
is case-sensitive with or without \c\ (§6); the option governs literals.
\-\pattern inverts the verdict: every label the pattern would have shown is hidden, and every other
label is kept.
\-\test every label that does not contain test
\-\a|b NOT (contains a OR contains b)
- Negation never inverts a refusal. A pattern that cannot be read still matches everything, so it hides nothing. Inverting that would hide every label over a typo, which is the worst outcome this language can produce and the one direction nobody watches.
\-\with nothing after it is refused. An empty pattern matches everything, so negated it matches nothing, and it is also the state\-\…passes through while it is being typed.\-\*is allowed: it says hide everything, and says it deliberately.
Its scope, stated plainly: \-\ inverts its item, so \-\a|b is a hide-list, NOT (a OR b).
Apple, but not test is apple&\-\test, which is this option applied to one item of two (§8). Until
& existed on 2026-10-12 it could not be written at all, and the specification said so here.
\b\app matches app, app-1, my app, app.md, app_data and an app.; it does not match
apple, snapple or MyAppCard.
A boundary is the edge of the label, or a neighbouring character that is not a letter or a number (
\p{L}/\p{N}, so it holds in any script).
The test looks only at the neighbouring character, never at the matched text, so it stays decidable
by reading one character. The requirement applies to the whole match extent, just before the first
matched character and just after the last, not around every token, so \b\app*pie is one run from app
to pie. At a label edge it is satisfied trivially, so \b\`app is just the anchor.
It is not a regular expression's \b, which counts _ as a word character: that would refuse
app_data for a whole-word app, and _ separates words in a filename whatever a regex thinks.
| Option | Means |
|---|---|
c |
case-sensitive literals; a set is case-sensitive regardless |
- |
not: invert the verdict |
b |
word boundary |
They compose in any order: \c-\, \-b\, \c-b\.
\…\ is an instruction namespace. A section may hold letters, digits and -, and the namespace
claims no punctuation: \.foo\.bar is two escaped dots around literals and stays that way, so an
instruction that one day needs = or , claims that character then and pays for it then.
- An unknown instruction is refused, not ignored.
\d\fooonce silently meantfoo; it now names the instructions that exist. This is what makes adding one safe:\b\appwas an error beforebexisted, never a pattern that quietly meantbapp. - The section needs at least one character.
\\is an escaped backslash (§9), not an empty section. Read as one, it stripped itself and left the empty pattern, which matched every label.
The section is read once, from the start of its item, before that item is split on | (§8). So a
section written at the start of a later alternative was never an option:
\-\apple|pear NOT (contains apple OR contains pear)
apple|\-\pear refused
The second spelling reads as apple, or not pear and could never have meant it. It is refused for every
instruction character, and the refusal names the section and says to move it to the start of its item.
This covers a ||…|| branch, and a second section written after a real one.
apple&\-\pear is not this shape and is allowed: the section opens an item, which is a whole
pattern, rather than an alternative inside one. That distinction is the whole difference between the
spelling this refuses and the one §8 added.
| Pattern | Meaning |
|---|---|
apple |
case-insensitive, contains apple |
apple*pie |
apple, then anything, then pie |
`apple |
starts with apple |
apple` |
ends with apple |
`apple` |
exactly apple |
[123] |
one character from 1, 2, 3 |
[0-9] |
one digit; also [a-z], [A-Za-z], [0-9A-F] |
foo[123]bar |
foo, one character from 123, then bar |
`[123]bar |
starts with one character from 123, then bar |
bar[456]` |
bar, one character from 456, at the end |
`[123]bar[456]` |
an exact full-label pattern |
apple|banana |
contains apple OR contains banana |
apple&banana |
contains BOTH, in either order |
apple&\-\test |
contains apple AND does NOT contain test |
apple&, apple| |
apple: one trailing operator is dropped, so a half-typed pattern still filters |
a|b&c |
(a OR b) AND c: & binds looser than |, unlike the C family |
||a|b||&c |
the same thing with the grouping made explicit |
*.||md|txt|| |
*.md OR *.txt: a group writes the shared part once |
`||a|b||` |
exactly a OR exactly b |
\c\apple |
case-sensitive, contains apple |
\c\`apple |
case-sensitive, starts with apple |
\-\apple |
every label that does NOT contain apple |
\b\app |
app as a whole word |
\c-\App |
options compose: case-sensitive AND negated, so every label without App |
\* |
a literal *; likewise |, \&, \`, \\, \[, \] |
The language deliberately has only seven reserved characters:
* | & ` \ [ ]
There are no:
- parentheses
- lookahead/lookbehind
- capture groups
- regex flags
- boolean keywords
- general regex operators
The most common operation, searching for a label containing some text, requires no special syntax:
engine
Labels are matched case-insensitively unless the pattern explicitly begins with:
\c\
The syntax starts with simple contains matching and adds specificity only when required:
engine
engine*part
`engine
engine`
`engine`
[0-9]engine
The pattern language is not intended to be a simplified regular-expression language.
Only the explicitly defined operators have special meaning.
A pattern is read in one pass, in this order:
- One trailing unescaped
&, or one trailing lone|, is dropped (§8, A trailing operator is not there). - Unescaped
&separates the items (§8), before anything else, because it is the loosest operator. A&inside a||…||group is an error. - The option section of each item, if that item begins with
\and a second unescaped\follows with at least one instruction character between them (§10). It is read once, off that item. ||…||groups expand into plain alternatives (§8).- Unescaped
|separates the remaining alternatives of the item. - Each alternative is tokenised independently.
pattern
→ item ("&" item)*
item
→ [option-section] alternatives
option-section
→ "\" instruction-character+ "\"
alternatives
→ alternative ("|" alternative)*
alternative
→ [start-anchor] token* [end-anchor]
token
→ literal
| wildcard
| character-set
character-set
→ "[" set-body "]"
start-anchor, end-anchor
→ "`"
A backtick is an anchor by position, not by context: the first character of an alternative, the last
character, or an error. There is no pairing to track, no parity to count and no lookahead. That is the
whole benefit of writing a set as […], and it is why §7 has nothing left to resolve.
Escaped characters are always literals, and a set body is scanned to its closing ] with only \\,
\] and \- meaningful inside it (§6).
Each alternative independently produces a match result, and each item is the OR of its alternatives.
The overall pattern matches if:
EVERY item matches, where an item matches if ANY of its alternatives does
A pattern with no & is one item, so this is the rule it has always been for every pattern written
without one.
An unanchored pattern searches anywhere within the label.
For example:
foo
is conceptually equivalent to:
*foo*
A leading backtick constrains the match to the beginning of the label.
A trailing backtick constrains the match to the end of the label.
A character set:
[123]
always consumes exactly one character.
A position in a label is a code point, not a UTF-16 code unit. So `🙂 is one character at the
start, [🙂] is a set of one character, and * consumes whole characters rather than halves of them.
An implementation whose string type indexes by code unit must convert before matching, or an emoji
counts as two and every anchor and set near one is off by one.
Case folding is applied per character and must preserve length, so a folded label and a raw label stay index-aligned. Where a language's own case conversion would change the length of a string, the character is left as it is rather than folded.
An unreadable pattern matches every label and carries the reason alongside the result. It does not match nothing.
One unreadable item makes the pattern unreadable. It is never combined as this item did not
match: apple&[0-9 would then mean contains apple and nothing matches, an empty list produced
confidently out of one missing bracket. Conjunction is the one operator that can turn a typo into an
empty result, so it is the one place this rule has to be stated rather than inferred.
A filter is the one control whose whole job is to decide what its reader is shown, so a pattern nobody could read must not remove rows for a reason nobody can see. Matching everything is visibly wrong and hides nothing; a confident empty list is invisibly wrong. The reason is reported so that a host can show it, and a host must also treat it as do not act on this pattern.
Negation does not invert this (§10).
Given:
[
"Apple",
"Apple Pie",
"Green Apple",
"Pineapple",
"Banana",
"Banana Bread",
"1bar4",
"2bar5",
"3bar6",
"x1bar4"
]
apple
matches:
Apple
Apple Pie
Green Apple
Pineapple
because matching is case-insensitive by default.
\c\apple
matches lowercase apple but not uppercase Apple.
`Apple
matches:
Apple
Apple Pie
Apple`
matches:
Apple
Green Apple
Pineapple
`Apple`
matches Apple, plus case variants under the default case-insensitive mode.
[123]bar
matches:
1bar4
2bar5
3bar6
because the default behavior is contains.
`[123]bar
matches:
1bar4
2bar5
3bar6
but not:
x1bar4
`[123]bar[456]`
matches:
1bar4
2bar5
3bar6
but not:
x1bar4
1bar4x
\c\`[A-Z]foo
means:
case-sensitive, starts with one uppercase letter, followed by
foo.
Apple|Banana
matches labels containing either term.
Apple&Pie
matches Apple Pie alone. Apple, Green Apple and Pineapple all hold the first item and none of
them holds the second.
Apple&\-\Green
matches Apple, Apple Pie and Pineapple, and excludes Green Apple. This is include, except,
and it is the example §8 and §10 both used to say could not be written.
bar&[13]
matches 1bar4, 3bar6 and x1bar4: every label holding bar and also holding a 1 or a 3.
Order does not matter to &, so x1bar4 matches although its digit precedes bar.
Apple|Banana&Bread
matches Banana Bread: & binds looser than |, so this is (Apple or Banana) and Bread rather
than Apple, or (Banana and Bread). Written ||Apple|Banana||&Bread it means the same thing with the
grouping shown, which is worth doing once a pattern is long enough for the eye to need it.
The matcher should parse the pattern into a small internal representation rather than treating the syntax itself as regex.
For example:
\c\`[123]bar[456]`
could become conceptually:
OPTIONS:
CASE_SENSITIVE
PATTERN:
START
CHARSET("123")
LITERAL("bar")
CHARSET("456")
END
while:
foo*bar|[123]baz
could become:
[
LITERAL("foo")
ANY
LITERAL("bar")
]
OR
[
CHARSET("123")
LITERAL("baz")
]
This keeps the public language small and deterministic and prevents implementation details of a regex engine from becoming part of the label-filter specification.
This specification text is licensed CC BY 4.0. Copyright 2026 Steven Spungin.
The implementations are MIT, which is a different licence for a different thing: the package's
license field names MIT because that is what the code is, and this document travels inside the same
tarball under the licence above. Specification text is CC BY 4.0, and a
package carrying both says so rather than letting the manifest speak for the prose.