---
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: lastIndexOf (subString, fromIndex)
layout: subsection
---

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

Returns the index of the last occurrence of the specified substring. This function searches backward starting at the specified index.

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

`int`

## <a id="section_dz5_pwg_5db"></a>Instance Method Syntax

```
thisString.lastIndexOf(subString, fromIndex)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>subString</td><td>The string to find within the input string.</td></tr><tr><td>startIndex</td><td>A zero-based starting position within the first string.</td></tr></tbody></table><br/>

<b>Example</b>

`'foobarfoobar'.lastIndexOf('oo', 6)`

Returns `1`

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

```
string:lastIndexOf(string, subString, fromIndex)
```

<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>string</td><td>The input String.</td></tr><tr><td>subString</td><td>The string to find within the input string.</td></tr><tr><td>fromIndex</td><td>A zero-based starting position within the first string.</td></tr></tbody></table><br/>

<b>Example</b>

`string:indexOf('Hello World!', 'o', 0)`

Returns `4`

