---
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: replaceSubstring (string, origSubstring, newSubstring)
layout: subsection
---

## <a id="section_m3p_myb_5db"></a>Description

Replaces the substring within the given string with the new substring if present, and returns the new string.

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

```
string:replaceSubstring(string, origSubstring, newSubstring)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>string</td><td>The input String.</td></tr><tr><td>origSubstring</td><td>A substring to replace.</td></tr><tr><td>newSubstring</td><td>The new substring.</td></tr></tbody></table><br/>

<b>Example</b>

`string:replaceSubstring('My longer string', 'longer', 'even longer')`

Returns `'My even longer string'`

