# Search templates, modifiers, and script constraints

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/2026.3/llms.txt).

When you construct a template for a structural search you are basically writing a script. To simplify your scripting process, GoLand offers you a list of predefined search templates that you can use as prototypes for your search template.

![Existing search templates for HTML](https://resources.jetbrains.com/help/img/idea/2026.3/go_ssr_list_of_templates.png)

![the Existing Templates dialog](https://resources.jetbrains.com/help/img/idea/2026.3/ws_existing_templates.png)

On how to access the list of the existing search and replace templates, see the [structural search and replace](structural-search-and-replace.html) section.

Each search or replace template consists of variables `$variable_name$` to which you can add a condition (modifier) to narrow your search results. Modifiers depend on a variable in your search template.

## Count modifier

The Count modifier specifies a number of occurrences.

If you do not set the Count modifier explicitly, the IDE looks for only one template match. In other words, when the Count modifier is not applied, the default values for the modifier are `min = 1` and `max = 1`.

GoLand adds `[0,∞]` to the variable and searches for the specified range of numbers.

## Reference modifier

The Reference modifier lets you reference some other search template in the variable.

The reference will always contain the name of a preconfigured or saved template, and you can use auto-completion to fill out this field.

## Type modifier

The Type modifier adds a type of the value or expression that is expected for the specified variable.

## Text filter

The Text modifier checks the variable against regular expressions or plain text.

For example, the `var\d` value for the `text` modifier in the `expression` context will find all the variables that start with `var` and have one digit afterwards.

![Text modifier](https://resources.jetbrains.com/help/img/idea/2026.3/go_ssr_text_filter.png)

## Script constraints

The Script modifier adds Groovy script constraints to the search template. Script constraints are used when you search for certain language constructs.

All variables used in a template can be accessed from script constraints. When you add a script constraint to your variable, GoLand matches it against the PSI tree, this variable is in fact a [node in the PSI tree](https://plugins.jetbrains.com/docs/intellij/psi-elements.html).

> **Note:**
> You can refer to any normal variable, for example, `$a$` in a template from a script modifier by using its name, for example, `a`, and do something with its value on any match.
>
>
>
> With __context__, you can refer to the entire template (complete match).

## See also

### Procedures

[Structural search and replace](structural-search-and-replace.html)

### Tutorials and Examples

