Pattern Matching

From The Foundry MODO SDK wiki
Revision as of 00:03, 2 April 2012 by Jangell (Talk | contribs)

Jump to: navigation, search

modo features a basic yet powerful pattern matching system based loosely on the design from AmigaOS. Some commands support pattern matching, as do the 'F' search fields in many parts of modo's user interface.

The following table describes the syntax used by modo's pattern matching mechanism. Expression is defined as a single character, or characters wrapped in parentheses or square braces as described below.

Syntax Description Example
Inputs Pattern Matches
* Zero or more of any characters. Apple, Apricot, Grape Ap* Apple, Apricot
# Zero or the next sub pattern. Ae, Ape, Appe, App, Axe A#pe Ae, Ape, Appe
? Any single character. a? will match any two-characer strings starting with a. #? means "any number of any characters", and is functionally identical to * Axe, Ape, Asp A?e Axe, Ape
~ Negates the following expression. For example, #~x? will match any two letter string except thoe starting with x. Similarly, ~(x?) will match anything except a two letter string beginning with x (so, xxa or ab but not xa). Axe, Ape, Asp A~xe Ape, Asp
( | ) Any one of the items separated by the vertical bar character. Any number of vertical bars can be used, including none. Axe, Ape, Abe A(x|b)e Axe, Abe
[abc] Any one of the characters inside the square braces. Axe, Ace, Abe, Abc, ACE A[bcBC]e Ace, Abe, ACE
[a-z] Any of the range of characters within the square braces. Multiple ranges cab be combined, such as [a-dA-Dxyz]. Axe, Ace, Abe, Ate, ABE A[a-kA-K]e Ace, ABE
' Escape from pattern matching. A[1], A[2], A(3) A'[?'] A[1], A[2]

Originally based on the description provided by the Amiga User Interface Guide, pages 108-110. Notable differences are that % is not currently supposed and a comma is not required between ranges in the [a-z] syntax.