Difference between revisions of "Pattern Matching"

From TouchDesigner Documentation
Jump to: navigation, search
Line 4: Line 4:
 
|Long=
 
|Long=
 
}}
 
}}
Many CHOPs allow patterns to specify multiple channels to be selected or acted upon. These patterns allow wild cards which will match all or parts of strings. Patterns are also used in various Python methods such as <code>ops()</code>, to allow specifying more than one OP by a single string.
+
Many parameters allow patterns to specify multiple sources to be selected or acted upon. CHOPs, channels, DATs, Geometry COMPs are examples of things that some parameters may allow multiple of. These patterns allow wild cards which will match all or parts of strings. Patterns are also used in various Python methods such as <code>ops()</code>, to allow specifying more than one OP by a single string.
 +
 
 +
Multiple patterns can be specified, separated by spaces. The patterns will be ORed together, so a source that matches any of listed patterns will be selected.
  
 
* <code>*</code> - Match any sequence of characters   
 
* <code>*</code> - Match any sequence of characters   

Revision as of 18:28, 5 November 2018


Many parameters allow patterns to specify multiple sources to be selected or acted upon. CHOPs, channels, DATs, Geometry COMPs are examples of things that some parameters may allow multiple of. These patterns allow wild cards which will match all or parts of strings. Patterns are also used in various Python methods such as ops(), to allow specifying more than one OP by a single string.

Multiple patterns can be specified, separated by spaces. The patterns will be ORed together, so a source that matches any of listed patterns will be selected.

  • * - Match any sequence of characters
  • ? - Match any single character
  • ^ - Do not match.
  • [alphaset] - Match any one of alphabetic characters enclosed in the square brackets. In TouchDesigner, the [a-g] format is not currently supported, the characters must be listed as [abcdefg].
  • [num1-num2] or [num1-num2:increment] - Match any integer numbers enclosed in the number range, with the optional increment.
  • [num1,num2,num3] - Match the specific integers given.
  • @groupname - Expands all the items in the group. Since each group belongs to a network, you can specify a path before the @groupname identifier.

NOTE: The opposite of pattern matching is Pattern Expansion, takes a short string and generates a longer string from it.

Pattern matching is also often used to match channel names. It uses the following kinds of patterns to select existing channels in an input CHOP, used in CHOPs like the Select CHOP and the Math CHOP's Scope parameter, where you only want to affect certain channels and leave the reset as-is.

Pattern matching is used to match object names in the Render TOP, and OPs/channel names in the Select CHOP.

Examples[edit]

chan2 Matches a single channel name
chan3 tx ty tz Matches four channel names, separated by spaces
chan* Matches each channel that starts with "chan" and ends with anything
*foot* Matches each channel that has "foot" in it, with anything or nothing before or after
t? The ? matches a single character. t? matches two-character channels starting with t, like the translate channels tx, ty and tz
r[xyz] Matches channels rx, ry and rz. that is, "r" followed by any character between the [ ]
blend[3-7:2] Matches number ranges giving blend3, blend5, and blend7. (3 to 7 in steps of 2)
blend[2-3,5,13] Matches channels blend2, blend3, blend5, blend13
t[uvwxyz] [uvwxyz] matches characters between u and z, giving channels tu, tv, tw, tx, ty and tz

See Also[edit]

An Operator Family which operate on Channels (a series of numbers) which are used for animation, audio, mathematics, simulation, logic, UI construction, and many other applications.

A parameter in most CHOPs that restricts which channels of that CHOP will be affected. Normally all channels of a CHOP are affected by the operator.