# Text Functions

Formula Pro custom text functions including regex support and string checks.

***

## CONTAINS

Checks whether a string contains another string. Case-sensitive by default.

**Syntax:** `CONTAINS(target, searchString, [caseSensitive])`

| Parameter     | Description                           |
| ------------- | ------------------------------------- |
| target        | The string to search in               |
| searchString  | The substring to find                 |
| caseSensitive | Optional. `true` (default) or `false` |

**Example:**

```
CONTAINS("Formula Pro", "Pro")
```

**Result:** `true`

**Example:**

```
CONTAINS("Formula Pro", "pro", false)
```

**Result:** `true` (case-insensitive)

**Example:**

```
CONTAINS("Formula Pro", "Excel")
```

**Result:** `false`

***

## TEXT

Formats a number as text using Excel-style format codes. Wraps Formula.js TEXT.

**Syntax:** `TEXT(value, format_text)`

**Example:**

```
TEXT(1234.56, "0.00")
```

**Result:** `"1234.56"`

**Example:**

```
TEXT(DATEVALUE("2025-03-09"), "YYYY-MM-DD")
```

**Result:** `"2025-03-09"`

***

## REGEXREPLACE

Replaces text matching a regex pattern. Supports replacement of all matches or a specific occurrence.

**Syntax:** `REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])`

| Parameter         | Description                                                                   |
| ----------------- | ----------------------------------------------------------------------------- |
| text              | Input text                                                                    |
| pattern           | Regex pattern (as string)                                                     |
| replacement       | Replacement string (supports `$1`, `$2` for capture groups)                   |
| occurrence        | Optional. `0` = replace all (default); `1`, `2`, ... = replace Nth match only |
| case\_sensitivity | Optional. `0` = case sensitive (default); `1` = case insensitive              |

**Example: Replace all occurrences**

```
REGEXREPLACE("tuttle", "t", "b")
```

**Result:** `"bubble"`

**Example: Replace specific occurrence**

```
REGEXREPLACE("tuttle", "t", "b", 2)
```

**Result:** `"tubtle"` (only second "t" replaced)

**Example: Capture groups**

```
REGEXREPLACE("2026-03-13", "(\d{4})-(\d{2})-(\d{2})", "$2/$3/$1")
```

**Result:** `"03/13/2026"`

**Example: Case-insensitive**

```
REGEXREPLACE("Product Vision", "vision", "plan", , 1)
```

**Result:** `"Product plan"`

***

## REGEXTEST

Tests whether text matches a regex pattern. Returns `true` or `false`.

**Syntax:** `REGEXTEST(text, pattern, [case_sensitivity])`

| Parameter         | Description                                            |
| ----------------- | ------------------------------------------------------ |
| text              | Text to test                                           |
| pattern           | Regex pattern                                          |
| case\_sensitivity | Optional. `0` = case sensitive; `1` = case insensitive |

**Example:**

```
REGEXTEST("hello@example.com", "@")
```

**Result:** `true`

**Example:**

```
REGEXTEST("Product-123", "^\d+$")
```

**Result:** `false` (string is not all digits)


---

# Agent Instructions: 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:

```
GET https://formulapro.shadebridge.com/formula-pro/formula-pro-custom-functions/text.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
