Searching, Finding, and Replacing Text
Press Ctrl+F, click the Find button in the Quick Access Toolbar, or choose Find and Replace () from the Windows menu to open the Find and Replace window that you can use to search for and replace variables or text in all of the model or, for application development, only in methods.
In this window, enter a search string in the text field under the window’s toolbar. The default label is Contains, and it represents a search that contains the entered text. From the Search Options () menu, you can also select to search for Contains word or a Regular expression. The text for the search field then updates to reflect the search option you use. The Contains word option looks for a single word in a sentence or a variable name in an expression. The Case Sensitive button () that just ensures that matches respect the case in the search field. Use the Regular expression option for more advanced search patterns, which also support group matches (see any online resource about regular expressions for details). Click the Search button () to update the search.
When working in the Physics Builder (see the Physics Builder Manual for more information), the Search Options menu contains an additional item named Scope of Search (). Choosing this option opens the Scope of Search dialog, which contains two check boxes:
Follow imports — Select this option to widen the scope of the search to files imported into the file you are currently working on.
Follow link sources — Select this option to extend the search to any links contained in your current file.
For each of these options you can specify the number of levels to follow by entering a positive integer in the Depth text field.
In the top toolbar you also find the Add Filter () and the Search History () menus; see the section below for more details on these menus. Click the Select Node button () to select the node in the model tree for the selected row in the list of search result and move to the settings where the search found that search string.
Under the search field there is a Replace with field. In that text field enter the text that you want to replace the matches with. Next to this field you find the Replace menu (), which contains two replace options: Replace Checked and Replace All. Use Replace All to replace all matches that can be replaced in the last search. The Replace Checked option only replaces the matches that you have selected in the result table below.
Under the search settings you find the search results as a table with nodes in a tree structure. All matches are leaves of the tree and also appear on a row with information about the search. The actual tree nodes represent nodes in the Model Builder, although the structure can differ slightly. Nodes that exist only because it is a parent to a match do not contain any data in their rows because they are not matches. Parent nodes can be collapsed to hide unimportant matches from the result. Below the table there are two fields that updates when you select rows in the table. If you select a single row, the Text field shows the currently selected match, with the matched text highlighted in a different color. The Preview field shows the replacement based on the Replace with text with the replaced text highlighted in a different color.
The Add Filter Menu
The supported filters are Node Filter, Descriptions, and Settings.
The Node Filter can limit what tree nodes to show in the search results. When you add a Node Filter, the Node Filter dialog box appears with settings for matching nodes: The Filter list contains the Node tags, Node labels (the default), Node names, and Node types options. Each option searches for the corresponding property and matches it against the text in the Find field. You can also choose to specialize the search with the Contains word, Regular expression, and Case sensitive check boxes under Options. They have the same meaning as the main search options. When you click OK the filter becomes visible in the Find and Replace window above the results table as a Node Filter menu, where you can choose Edit () to open the Node Filter dialog box and Remove () to remove the filter.
The Descriptions filter option limits the search to only search for descriptions (read-only labels in the user interface). This filter do not need any settings, so its toolbar menu only contain the Remove option. Also note that replace is not supported for descriptions.
To filter with respect to certain settings, use the Settings filter, and when you select it, the Settings dialog box appears. The Name field contains the text that matches the name of a setting (the label shown in the user interface). The value of the setting is what the main search field matches against. The filter supports the same options as the Node Filter but also includes two extra options:
Select the Include API names in search check box to allow the match to also look for the names and values used by the COMSOL API, or in words the code used to access a setting. Names are typically similar but different in almost all cases. Some examples are name for a Name setting and expr for an Expression setting. Check boxes and lists are typical examples of when the values differ from what you see in the user interface. Values of lists cannot be matched without this setting, and the corresponding API text is on or off for most nodes, except for physics that use 1 and 0 instead.
Select the Include hidden settings check box to allow the match to also look for settings that are hidden. Matches that are hidden get an extra Hidden label in the Type column (for example, Setting (Hidden)). Replacing them also works for hidden settings that can be altered. Finding and replacing that include hidden settings can be important when renaming variables.
The Search History Menu
Each search that you do will be listed in the Search History menu (). To redo a previous search with the same options, just select the search from this menu. The results can differ from the previous search if the model has changed since when you last did that search. The labels of each saved search contains an abbreviated list of the options used. The menu also contains the Open New Window and Clear Search History options. Choose Open New Window to open another Find and Replace window in the COMSOL Desktop. The Clear Search History option removes all saved searches in all open Find and Replace windows.