---
category: [, Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, PMD Scripting, Scripts]
nav: wcp_docs
parent_url: /wcp_docs/
title: replaceOnce (text, regex, replacement)
layout: subsection
---

## Description

Replaces the first substring of the input text that matches the regular expression with the specified replacement string.

## <a id="section_1"></a>Return Type

`string`

## <a id="section_2"></a>Namespace Function Syntax

```
regex:replaceOnce(text, regex, replacement)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>text</td><td>The input string.</td></tr><tr><td>regex</td><td>A regular expression to match within the input text.</td></tr><tr><td>replacement</td><td>The string that replaces the matched substring.</td></tr></tbody></table><br/>

<b>Examples</b>

`regex:replaceOnce('ABC123DEF', '[a-zA-Z]+', '000')`

Returns `'000123DEF'`.

