[Skip to content]
TRIEMAX Software
You are here: Home > Products > Jalopy >

### 2.6.13. Search & Replace

Lets you perform string Search & Replace operations during formatting.

Figure 2.93. Search & Replace settings page

#### 2.6.13.1. Scope

Lets you configure the elements for which Search & Replace should be performed.

##### String Literals

Enables Search & Replace for string literals. Please note that you first need to define at least one pattern in order to be able to enable Search & Replace! See Section 2.6.13.2, "Patterns" for information on adding patterns.

Since 1.7

Example 2.837. String literal

    String literal = "String literals are enclosed in double quotes";

##### Single-line comments

Enables Search & Replace for single-line comments. Please note that you first need to define at least one pattern in order to be able to enable Search & Replace! See Section 2.6.13.2, "Patterns" for information on adding patterns.

Since 1.7

Example 2.838. Single-line comment

    // Single-line comments are similar like in C++

##### Multi-line comments

Enables Search & Replace for multi-line comments. Please note that you first need to define at least one pattern in order to be able to enable Search & Replace! See Section 2.6.13.2, "Patterns" for information on adding patterns.

Since 1.7

Example 2.839. Multi-line comment

    /* Multi-line comments are similar like in C/C++ */

##### Javadoc comments

Enables Search & Replace for Javadoc comments. Please note that you first need to define at least one pattern in order to be able to enable Search & Replace! See Section 2.6.13.2, "Patterns" for information on adding patterns.

Since 1.7

Example 2.840. Javadoc comment

    /**
     * Javadoc comments are basically multi-line comments using
     * a special notation
     */

#### 2.6.13.2. Patterns

Lets you define regular expression patterns to use for Search & Replace. You can define an arbitrary amount of Search & Replace patterns that are executed in the order defined when formatting a file.

The used regular expression syntax is that of Perl 5.003. See Mastering Regular Expressions [Friedl97] for an in-depth look at this regular expression flavor.

The list component displays all patterns currently defined. Use the button bar on the right to add, remove or change patterns and define the order in which the patterns should be applied.

##### Add...

Lets you add new Search & Replace patterns. Pressing the button will invoke a new dialog where you can enter the Search & Replace patterns.

Figure 2.94. Add Search & Replace pattern

Enter the search pattern in the Search for text field and the replace pattern in the Replace with text field.

The replace pattern may contain variable interpolations referring to the saved parenthesized groups of the search pattern. A variable interpolation is denoted by $1, $2, or $3, etc.

Suppose you have the search pattern b\d+: and you want to substitute the b's for a's and the colon for a dash in parts of your input matching the pattern. You can do this by changing the search pattern to b(\d+): and using the replace pattern a$1-. When a substitution is made, the $1 means "Substitute whatever was matched by the first saved group of the matching pattern." An input of b123: after substitution would yield a result of a123-.

For the given patterns

    Tank b123: 85  Tank b256: 32  Tank b78: 22

would become

    Tank a123- 85  Tank a256- 32  Tank a78- 22

##### Change...

Lets you alter an already defined Search & Replace pattern.

This button is only available if an item is currently selected in the pattern list. Pressing the button will invoke a new dialog where you can change the Search & Replace patterns for the currently selected item in the pattern list.

Figure 2.95. Change Search & Replace pattern

Please refer to "Add Pattern dialog" for an explanation of the available regular expression capabilities.

##### Remove

Lets you remove an already defined Search & Replace pattern.

This button is only available if an item is currently selected in the pattern list.

##### Up

Lets you change the position of an already defined Search & Replace pattern in the pattern list.

This button is only available if an item is currently selected in the pattern list and this is not the topmost item.

##### Down

Lets you change the position of an already defined Search & Replace pattern in the pattern list.

This button is only available if an item is currently selected in the pattern list and this is not the last item.