Products Applications Downloads Features Wiki forum Store

Pattern Matching

From Wiki077
Jump to: navigation, search

Many of the op* and ch* commands allow patterns to specify multiple objects or channels. These patterns allow wild cards which will match all or parts of strings.

  • * - Match any sequence of characters
  • ? - Match any single character
  • ^ - Do not match.
  • [alphaset] - Match any alphabetic characters enclosed in the square brackets. In Touch, 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.
  • @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.

Examples

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

Using Pattern Matching in Commands

opcd/obj ; opls -d @geo 

This example lists all the objects in the group named "geo".

opcd /obj/geo1 ; chadd @xform_sops tx ty tz 

This example adds channels (tx, ty and tz) to all the SOPs contained in the xform_sops group.

opcd /mat ; opls /obj/@lights 

This example shows how to reference groups outside of the current folder.

See Also

Personal tools