Experimental:Pattern Expansion

From Derivative
Jump to navigation Jump to search

Experimental - Skipping Glossary

Pattern Expansion takes a short string and expands it to generate a longer string of individual elements. Example: chan[1-3] generates chan1 chan2 chan3.

Pattern Replacement uses Pattern Expansion, along with having some of it's own syntax on-top of Pattern Expansion. Pattern Expansion is different from "Pattern Matching", in Pattern Expansion you are creating a list of strings, while in Pattern Matching you are looking for a pattern in a string or a set of strings.

Expansion is done by using putting the data to expand into []. Valid syntax is

  • [alphaset]- Where alphaset is one or more letters (not numbers), each of which will be split out into it's own result. The [a-g] format is not currently supported, the characters must be listed as [abcdefg]
  • [int1-int2] - Where int1 and int2 form a range of numbers. A result will be created for each number in the range.
  • [int1-int2:increment] - Similar to the previous one, but increment allows for skipping numbers in the range.
  • [int1,int2,int3] - Match the specific integers given

Note Each expansion will be expanded against every possible other expansion in the string. So one expansion with 2 results followed by one with 3 results, will result in a final result containing 6 results. The order the numbers and ranges appear in [] is the order they are generated. See examples below.

Examples[edit]

[tr][xyz] Starts expansion from right to left. Expands to tx ty tz rx ry rz
chan[1-11:2] Starts expansion at chan1 to chan11 in increments of 2. Expands to chan1 chan3 chan5 chan7 chan9 chan11
chan[1-3] pos[xyz] Starts expanding first term, and then the second. Expands to chan1 chan2 chan3 posx posy posz

Pattern expansion occurs in:

Note: See tdu.expand()

Note: To expand a list of operators that is in a parameter type that is a list of operators, see .evalOPs() in Par Class

See also Pattern Replacement, Pattern Matching.