Difference between revisions of "Pattern Matching"

From The Foundry MODO SDK wiki
Jump to: navigation, search
(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...")
 
Line 1: Line 1:
 
''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.
 
''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.
+
In this table, ''expression'' is defined as a single character, or characters wrapped in parentheses or square braces as described below.
  
 
{| align="center"
 
{| align="center"
Line 15: Line 15:
 
|-
 
|-
 
|<nowiki>*</nowiki>
 
|<nowiki>*</nowiki>
|Zero or more of any characters
+
|Zero or more of any characters.
 
|Apple, Apricot, Grape
 
|Apple, Apricot, Grape
 
|Ap*
 
|Ap*
Line 21: Line 21:
 
|-
 
|-
 
|<nowiki>#</nowiki>
 
|<nowiki>#</nowiki>
|Zero or the next subpattern
+
|Zero or the next sub pattern.
 
|Ae, Ape, Appe, App, Axe
 
|Ae, Ape, Appe, App, Axe
 
|A#pe
 
|A#pe
Line 27: Line 27:
 
|-
 
|-
 
|<nowiki>?</nowiki>
 
|<nowiki>?</nowiki>
|Any single character.  ''#?'' means "any number of any characters", and is functionally identical to ''*''
+
|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
 
|Axe, Ape, Asp
 
|A?e
 
|A?e
Line 39: Line 39:
 
|-
 
|-
 
|<nowiki>(  |  )</nowiki>
 
|<nowiki>(  |  )</nowiki>
|Matches any one of the items separated by the vertical bar character.  Any number of vertical bars can be used, including none.
+
|Any one of the items separated by the vertical bar character.  Any number of vertical bars can be used, including none.
 
|Axe, Ape, Abe
 
|Axe, Ape, Abe
 
|A(x|b)e
 
|A(x|b)e
Line 45: Line 45:
 
|-
 
|-
 
|<nowiki>[abc]</nowiki>
 
|<nowiki>[abc]</nowiki>
|Matches any one of the characters inside the square braces.
+
|Any one of the characters inside the square braces.
 
|Axe, Ace, Abe, Abc, ACE
 
|Axe, Ace, Abe, Abc, ACE
 
|A[bcBC]e
 
|A[bcBC]e
Line 51: Line 51:
 
|-
 
|-
 
|<nowiki>[a-z]</nowiki>
 
|<nowiki>[a-z]</nowiki>
|Matches any of the range of characters within the square braces.  Multiple ranges cab be combined, such as ''[a-dA-Dxyz]''.
+
|Any of the range of characters within the square braces.  Multiple ranges cab be combined, such as ''[a-dA-Dxyz]''.
 
|Axe, Ace, ABE, Ate
 
|Axe, Ace, ABE, Ate
 
|A[a-kA-K]e
 
|A[a-kA-K]e

Revision as of 23:48, 1 April 2012

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 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 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 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.