Difference between revisions of "Palette:searchReplace"

From TouchDesigner Documentation
Jump to: navigation, search
Line 9: Line 9:
 
==Search/Replace==
 
==Search/Replace==
  
Version <code>Version</code> - Component version number.
+
'''Version''' <code>Version</code> - Component version number.
  
Help <code>Help</code> - Open this help page.
+
'''Help''' <code>Help</code> - Open this help page.
 
-----------------------
 
-----------------------
Search In OP <code>Searchinop</code> - Operator to search inside. All children of components will be searched recursively.
+
'''Search In OP''' <code>Searchinop</code> - Operator to search inside. All children of components will be searched recursively.
  
Search String <code>Searchstring</code> - The string to search for.
+
'''Search String''' <code>Searchstring</code> - The string to search for.
  
Replace String <code>Replacestring</code> - The string to replace searched string with.  
+
'''Replace String''' <code>Replacestring</code> - The string to replace searched string with.  
 
-------------------
 
-------------------
Go <code>Go</code> - Perform the chosen operation.
+
'''Go''' <code>Go</code> - Perform the chosen operation.
  
Operation <code>Operation</code> - Choose <code>Search Only</code> or <code>Search and Replace</code>.
+
'''Operation''' <code>Operation</code> - Choose <code>Search Only</code> or <code>Search and Replace</code>.
  
Open Result Table <code>Openresulttable</code> - Open a view of the search result table, which is also available through the Component's DAT output.
+
'''Open Result Table''' <code>Openresulttable</code> - Open a view of the search result table, which is also available through the Component's DAT output.
  
Clear Results Before Search <code>Clearresultsbeforesearch</code> - When on, clear the result table automatically before searching.
+
'''Clear Results Before Search''' <code>Clearresultsbeforesearch</code> - When on, clear the result table automatically before searching.
  
Clear Result Table <code>Clearresulttable</code> - Clear all search results from the result table.
+
'''Clear Result Table''' <code>Clearresulttable</code> - Clear all search results from the result table.
 
----------------------
 
----------------------
Search OP Names <code>Searchopnames</code> - Search operator names.
+
'''Search OP Names''' <code>Searchopnames</code> - Search operator names.
  
Search Par Page Names <code>Searchparpagenames</code> - Search parameter page names.
+
'''Search Par Page Names''' <code>Searchparpagenames</code> - Search parameter page names.
  
Search Par Names/Labels <code>Searchparnameslabels</code> - Seach parameter names and labels.
+
'''Search Par Names/Labels''' <code>Searchparnameslabels</code> - Seach parameter names and labels.
  
Search DAT Text <code>Searchdattext</code> - Search text in ''editable'' DATs.
+
'''Search DAT Text''' <code>Searchdattext</code> - Search text in ''editable'' DATs.
  
Search Par Data <code>Searchpardata</code> - Search parameter values and expressions.
+
'''Search Par Data''' <code>Searchpardata</code> - Search parameter values and expressions.
  
Search Menu Items <code>Searchmenuitems</code> - Search parameter menu items (names and labels).
+
'''Search Menu Items''' <code>Searchmenuitems</code> - Search parameter menu items (names and labels).
  
Case Sensitive <code>Casesensitive</code> - Case sensitive search.
+
'''Case Sensitive''' <code>Casesensitive</code> - Case sensitive search.
  
Whole Words <code>Wholewords</code> - Look for search string only when it is not part of a larger word. Any non alpha-numeric characters are considered word boundaries.
+
'''Whole Words''' <code>Wholewords</code> - Look for search string only when it is not part of a larger word. Any non alpha-numeric characters are considered word boundaries.
 +
:Example: Searching for 'par' with Whole Words on will find <code>me.par.limit</code> but will not find <code>parent</code>
  
Regular Expressions <code>Regularexpressions</code> - When on, search string will be processed as a regular expression. For information about using regular expressions, see [https://docs.python.org/3/library/re.html the Python documentation]. There are many other regular expression resources available online.  
+
'''Regular Expressions''' <code>Regularexpressions</code> - When on, search string will be processed as a regular expression.  
  
First N Matches <code>Firstnmatches</code> - Stop matching after finding the string in a given number of Operators.
+
'''First N Matches''' <code>Firstnmatches</code> - Stop matching after finding the string in a given number of Operators.
  
N <code>N</code> - The number of matches to stop after.
+
'''N''' <code>N</code> - The number of matches to stop after.
 +
 
 +
= Regular Expressions =
 +
This component gives you the option of using regular expressions, a powerful system used for string search and replace.
 +
'''Full Python documentation:''' [https://docs.python.org/3/library/re.html the Python documentation].
 +
An internet search will return many other regular expression resources as well.
 +
==Regular Expression examples==
 +
These are very simple examples of things you can do with regular expressions. See full documentation for more.
 +
:* <code>par.</code> &rarr; par followed by any character: pars, par1, parm
 +
:* <code>par...</code> &rarr; par followed by any three characters: parent, par123
 +
:* <code>par\.</code> &rarr; par followed by the '.' character: par. ONLY
 +
:* <code>par.*</code> &rarr; par followed by any number (including 0) of any character: parent, parsimonious, par1, parm, par
 +
:* <code>par1*</code> &rarr; par followed by any number (including 0) of the character "1": par, par1, par1111
 +
:* <code>par[a-e]</code> &rarr; par followed by a letter "a" through "e": para, pard, pare
 +
:* <code>par[^a-e]</code> &rarr; par followed by any character that is not the letters "a" through "e": parh, par1, par]
 +
:* <code>par[a-e]*</code> &rarr; par followed by any number of instances of the letters "a" through "e": paraaaa, par, pardae
 +
:* <code>par[a-eX]*</code> &rarr; par followed by any number of instances of the letters "a" through "e" or 'X': paraeXa, parX, par
 +
:* <code>par\d*</code> &rarr; par followed by any number of digits: par, par58123, par0
 +
:* <code>par\d\d*</code> &rarr; par followed by at least one digits: par, par58123, par0
 +
==Regular Expression Escape Sequences==
 +
There are a number of useful regular expression escape sequences (starting with backslash character). See full documentation for more.
 +
:* <code>\d</code>: a digit (0-9)
 +
:* <code>\s</code>: a whitespace character
 +
:* <code>\S</code>: a non-whitespace character
 +
:* <code>\w</code>: a "word" character (a-z, A-Z, 0-9, and _) (0-9)
 +
:* <code>\W</code>: a non-"word" character (a-z, A-Z, 0-9, and _) (0-9)
 +
==Replacements in Regular Expressions==
 +
Replacements are also extremely powerful in Regular Expressions, using a simple grouping system. Use parenthesis to separate any number of regular expressions, then in the replacement string, reference those groups using \g<#> with # being the group number. See full documentation for more info.
 +
===Examples===
 +
:* '''Search''': <code>dog(\d)</code> '''Replace''': <code>god\g<1></code> &rarr; dog3 becomes god3, dog0 becomes god0 etc.
 +
:* '''Search''': <code>(dog|god)(\d)</code> '''Replace''': <code>\g<2>\g<1></code> &rarr; dog3 becomes 3dog, god0 becomes 0god etc. '''Note''': the <code>|</code> character is an "or" in the group.
  
 
{{History}}
 
{{History}}

Revision as of 16:20, 12 June 2019

Summary[edit]

The searchReplace Component lets you search and (optionally) replace text in an operator or network.

It will search all text, including Operator names, custom parameter names and values, custom parameter menu items etc.

Parameters[edit]

Search/Replace[edit]

Version Version - Component version number.

Help Help - Open this help page.


Search In OP Searchinop - Operator to search inside. All children of components will be searched recursively.

Search String Searchstring - The string to search for.

Replace String Replacestring - The string to replace searched string with.


Go Go - Perform the chosen operation.

Operation Operation - Choose Search Only or Search and Replace.

Open Result Table Openresulttable - Open a view of the search result table, which is also available through the Component's DAT output.

Clear Results Before Search Clearresultsbeforesearch - When on, clear the result table automatically before searching.

Clear Result Table Clearresulttable - Clear all search results from the result table.


Search OP Names Searchopnames - Search operator names.

Search Par Page Names Searchparpagenames - Search parameter page names.

Search Par Names/Labels Searchparnameslabels - Seach parameter names and labels.

Search DAT Text Searchdattext - Search text in editable DATs.

Search Par Data Searchpardata - Search parameter values and expressions.

Search Menu Items Searchmenuitems - Search parameter menu items (names and labels).

Case Sensitive Casesensitive - Case sensitive search.

Whole Words Wholewords - Look for search string only when it is not part of a larger word. Any non alpha-numeric characters are considered word boundaries.

Example: Searching for 'par' with Whole Words on will find me.par.limit but will not find parent

Regular Expressions Regularexpressions - When on, search string will be processed as a regular expression.

First N Matches Firstnmatches - Stop matching after finding the string in a given number of Operators.

N N - The number of matches to stop after.

Regular Expressions[edit]

This component gives you the option of using regular expressions, a powerful system used for string search and replace. Full Python documentation: the Python documentation. An internet search will return many other regular expression resources as well.

Regular Expression examples[edit]

These are very simple examples of things you can do with regular expressions. See full documentation for more.

  • par. → par followed by any character: pars, par1, parm
  • par... → par followed by any three characters: parent, par123
  • par\. → par followed by the '.' character: par. ONLY
  • par.* → par followed by any number (including 0) of any character: parent, parsimonious, par1, parm, par
  • par1* → par followed by any number (including 0) of the character "1": par, par1, par1111
  • par[a-e] → par followed by a letter "a" through "e": para, pard, pare
  • par[^a-e] → par followed by any character that is not the letters "a" through "e": parh, par1, par]
  • par[a-e]* → par followed by any number of instances of the letters "a" through "e": paraaaa, par, pardae
  • par[a-eX]* → par followed by any number of instances of the letters "a" through "e" or 'X': paraeXa, parX, par
  • par\d* → par followed by any number of digits: par, par58123, par0
  • par\d\d* → par followed by at least one digits: par, par58123, par0

Regular Expression Escape Sequences[edit]

There are a number of useful regular expression escape sequences (starting with backslash character). See full documentation for more.

  • \d: a digit (0-9)
  • \s: a whitespace character
  • \S: a non-whitespace character
  • \w: a "word" character (a-z, A-Z, 0-9, and _) (0-9)
  • \W: a non-"word" character (a-z, A-Z, 0-9, and _) (0-9)

Replacements in Regular Expressions[edit]

Replacements are also extremely powerful in Regular Expressions, using a simple grouping system. Use parenthesis to separate any number of regular expressions, then in the replacement string, reference those groups using \g<#> with # being the group number. See full documentation for more info.

Examples[edit]

  • Search: dog(\d) Replace: god\g<1> → dog3 becomes god3, dog0 becomes god0 etc.
  • Search: (dog|god)(\d) Replace: \g<2>\g<1> → dog3 becomes 3dog, god0 becomes 0god etc. Note: the | character is an "or" in the group.


Palette
Palette • Palette:audioSet • Palette:battery • Palette:bloom • Palette:cameraBrowser • Palette:camSchnappr • Palette:changeColor • Palette:changeToColor • Palette:checker • Palette:chromaKey • Palette:colorThreshold • Palette:convolve • Palette:dent • Palette:depthExtract • Palette:dilate • Palette:feedback • Palette:feedbackEdge • Palette:geoPanel • Palette:gestureCapture • Palette:hsvBlur • Palette:imageSearch • Palette:julia • Palette:kantanMapper • Palette:kinectPointcloud • Palette:leapPaint • Palette:lightTunnel • Palette:mandelbrot • Palette:mesh • Palette:monochrome • Palette:motionSense • Palette:moviePlayer • Palette:noise • Palette:particlesGpu • Palette:pixelate • Palette:pixelRelocator • Palette:pointillize • Palette:popDialog • Palette:probe • Palette:pushPins • Palette:puzzle • Palette:radialBlur • Palette:remotePanel • Palette:rgbaBlur • Palette:rgbaDelay • Palette:rgbContrast • Palette:searchReplace • Palette:sharpen • Palette:softenAlpha • Palette:solarize • Palette:stitcher • Palette:stoner • Palette:superFormula • Palette:sweetSpotPreviz • Palette:TDVR • Palette:transitMap • Palette:twirl • Palette:webBrowser • Palette:xyScope

An Operator Family that contains its own Network inside. There are twelve 3D Object Component and eight 2D Panel Component types. See also Network Path.

Any of the procedural data operators. OPs do all the work in TouchDesigner. They "cook" and output data to other OPs, which ultimately result in new images, data and audio being generated. See Node.

An Operator Family that manipulates text strings: multi-line text or tables. Multi-line text is often a command Script, but can be any multi-line text. Tables are rows and columns of cells, each containing a text string.

A text string that contains data (string, float, list, boolean, etc.) and operators (+ * < etc) that are evaluated by the node's language (python or Tscript) and returns a string, float list or boolean, etc. Expressions are used in parameters, DATs and in scripts.

A built-in panel in TouchDesigner that contains a library of components and media that can be dragged-dropped into a TouchDesigner network.