> For the complete documentation index, see [llms.txt](https://docs.cloud.hoverfly.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloud.hoverfly.io/create-simulations/using-templating-in-simulations/useful-helper-functions.md).

# Useful helper functions

### Concatenate two strings

```handlebars
{{ concat '<string1>' '<string2>' }}
```

### Search and replace text in a string

```handlebars
{{ replace '<string-to-search>' '<string-to-replace>' '<replacement-string>' }}
```

### Create an array from a delimited string

This can be particularly useful when dealing with the results of a JSONPath query that returns an array, as these are space delimited strings of values.

```handlebars
{{ split '<delimited-string>' '<delimiter>' }}
```

### Change the HTTP response code

If you are following a pattern where you want a single request/response pair to return different HTTP response codes based on the outcome of logic, then you can do that using the following function:

```handlebars
{{ setStatusCode <any-valid-http-response-code> }}
```

### Set the value of an HTTP response header

You can set the value of an HTTP header dynamically from script:

```handlebars
{{ setHeader '<header-name>' '<new-value>'}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cloud.hoverfly.io/create-simulations/using-templating-in-simulations/useful-helper-functions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
