ArticleslgStudy

science

Wildmat

Wildmat is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Wildmat rather than just read about it. In short: wildmat is a pattern matching library developed by Rich Salz. Based on the wildcard syntax already used in the Bourne shell, wildmat provides a uniform mechanism for matching patterns across applications with simpler syntax than that typically offered by regular expressions.

Key takeaways

  • Wildmat belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Wildmat to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Wildmat from memory before moving on to harder problems.

Reference excerpt

wildmat is a pattern matching library developed by Rich Salz. Based on the wildcard syntax already used in the Bourne shell, wildmat provides a uniform mechanism for matching patterns across applications with simpler syntax than that typically offered by regular expressions. Patterns are implicitly anchored at the beginning and end of each string when testing for a match. In June 2019, Rich Salz released the original version of the now-defunct library on GitHub under a public domain dedication.

Pattern matching operations There are five pattern matching operations other than a strict one-to-one match between the pattern and the source to be checked for a match.

Asterisk (*) to match any sequence of zero or more characters. Question mark (?) to match any single character. Set of specified characters. It is specified as a list of characters, or as a range of characters where the beginning and end of the range are separated by a minus (or dash) character, or as any combination of lists and ranges. The dash can also be included in the set as a character if it is the beginning or end of the set. This set is enclosed in square brackets. The close square bracket (]) may be used in a set if it is the first character in the set. Negation of a set. It is specified the same way as the set with the addition of a caret character (^) at the beginning of the test string just inside the open square bracket. (NNTP specifies an alternative !. The implementation can be configured to do either.) Backslash (\) character to invalidate the special meaning of the open square bracket ([), the asterisk, backslash or the question mark. Two backslashes in sequence will result in the evaluation of the backslash as a character with no special meaning.

Examples *foo* matches string containing "foo". mini* matches anything that begins with "mini" (including the string "mini" itself). ???* matches any string of three and more letters. [0-9a-zA-Z] matches every single alphanumeric ASCII character. [^]-] matches a character other than a close square bracket or a dash.

Usage wildmat is most commonly seen in NNTP implementations such as Salz's own INN, also in unrelated software such as GNU tar and Transmission. GNU tar replaced wildmat with the POSIX fnmatch glob matcher in September 1992. The early version contained a potential out-of-bound access on unclosed [. The original byte oriented wildmat implementation is unable to handle multibyte character sets, and poses problems when the text being searched may contain multiple incompatible character sets. A simplified version of wildmat oriented toward UTF-8 encoding has been developed by the IETF NNTP working group. It is a part of RFC 3977 (section 4), the 2006 standard for NNTP. In the newer INN which supports UTF-8, a "uwildmat" was added which supports all the features of wildmat. This 2000 rewrite, performed by Russ Allbery, fixes the OOB in the original implementation. Tightly-wound C loops were written out into smaller statements. Rsync includes a GPLv3-licensed wildmat descendant known as wildmatch, modified by Wayne Davison. The Git version control system imports and makes use of it. It does not support UTF-8, but has the OOB fixed and has additional support for character classes and star globs (** for arbitrary-depth).

See also glob (programming) Kleene star Matching wildcards

References

External links Rich Salz (April 4, 1991). "v17i079: wildmat-1.4 - a /bin/sh-style pattern matcher, Part01/01". Newsgroup: comp.sources.misc. Usenet: 1991Apr4.034350.3923@sparky.IMD.Sterling.COM. Rich Salz (March 9, 1991). "v17i034: wildmat - a /bin/sh-style pattern matcher, Part01/01". Newsgroup: comp.sources.misc. Usenet: 1991Mar9.044016.2409@sparky.IMD.Sterling.COM.

Worked examples

Example 1 — a first encounter with Wildmat

Start with the simplest possible case. Write down what Wildmat claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Wildmat before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Wildmat ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Wildmat

In research
Wildmat appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Wildmat in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Wildmat is common in secondary-school and first-year university syllabi. It links to neighbouring topics Pattern matching, so understanding it makes those chapters shorter.
In everyday life
Look for Wildmat outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Wildmat in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Wildmat means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Wildmat out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Wildmat in simple terms?

wildmat is a pattern matching library developed by Rich Salz. Based on the wildcard syntax already used in the Bourne shell, wildmat provides a uniform mechanism for matching patterns across applications with simpler syntax than that typically offered by regular expressions.

Why does Wildmat matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Wildmat?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Wildmat.

Tags

  • Pattern matching

Keep exploring