Pattern Matching

From The Foundry MODO SDK wiki
Revision as of 23:46, 1 April 2012 by Jangell (Talk | contribs) (Created page with "''modo'' features a basic yet powerful pattern matching system based loosely on that originally available in AmigaOS. Some commands support pattern matching, as do the 'F' se...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

In this table 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 subpattern Ae, Ape, Appe, App, Axe A#pe Ae, Ape, Appe
? Any single character. #? 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
( | ) Matches any one of the items separated by the vertical bar character. Any number of vertical bars can be used, including none. Axe, Ape, Abe b)e Axe, Abe
[abc] Matches any one of the characters inside the square braces. Axe, Ace, Abe, Abc, ACE A[bcBC]e Ace, Abe, ACE
[a-z] Matches any of the range of characters within the square braces. Multiple ranges cab be combined, such as [a-dA-Dxyz]. Axe, Ace, ABE, Ate 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.