Difference between revisions of "Experimental:Palette:searchReplace"

From TouchDesigner Documentation
Jump to: navigation, search
(Blanked the page)
(Tag: Blanking)
Line 1: Line 1:
The '''searchReplace''' Component lets you search and (optionally) replace text in operators. The replace operation is '''undoable'''.
It will search and optionally replace all text in DATs, operator names, parameter values/expressions/bind expressions, custom parameter names, custom parameter menu items, custom parameter page names, and fieldCOMP text.
To search a single operator, or a component recursively, set the '''<code>Searchinop</code>''' parameter. The first input allows you to provide a table of operators (<code>'''path'''</code> column) to search non-recursively. The second input allows you to provide a table of multiple search/replace string options in <code>'''search'''</code> and <code>'''replace'''</code> columns.
'''Version''' <code>Version</code> - Component version number.
'''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 String''' <code>Searchstring</code> - The string to search for.
'''Replace String''' <code>Replacestring</code> - The string to replace searched string with.
'''Go''' <code>Go</code> - Perform the chosen operation.
'''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.
'''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.
'''Search OP Names''' <code>Searchopnames</code> - Search operator 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 DAT Text''' <code>Searchdattext</code> - Search text in ''editable'' DATs.
'''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 Field Text''' <code>Searchfieldtext</code> - Search the panel.field member of fieldCOMPs.
'''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.
: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.
'''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.
= Regular Expressions =
This component gives you the option of using regular expressions, a powerful system used for string search and replace. An internet search will return many other regular expression resources besides those below.
* [https://docs.python.org/3/library/re.html Full Python documentation]
* [https://towardsdatascience.com/the-ultimate-guide-to-using-the-python-regex-module-69aad9e9ba56 A great tutorial.]
* [https://regex101.com An online regular expression tester]
==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>par\b</code> &rarr; par followed by any word boundary, which amounts to anything that ends with "par": par, ropar, 12par,
:* <code>par1*</code> &rarr; par followed by any number (including 0) of the character "1": par, par1, par1111
:* <code>par1+</code> &rarr; par followed by any number (excluding 0) of the character "1": 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: par58123, par0
:* <code>par\w</code> &rarr; par followed by any word character: par1, para
==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 _)
:* <code>\W</code>: a non-"word" character (not a-z, A-Z, 0-9, or _)
==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 '''<code>\g<#></code>''' with # being the group number. See full documentation for more info.
:* '''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.

Latest revision as of 15:48, 21 May 2020