---
description: >-
  https://stackoverflow.com/questions/14867835/get-substring-between-two-characters-using-javascript
---

# Get Substring between two characters using javascript (ok)

Current

```
Str = 'MyLongString:StringIWant;'
```

Desired Output

```
newStr = 'StringIWant'
```

### Answers

```
var mySubString = str.substring(
    str.lastIndexOf(":") + 1, 
    str.lastIndexOf(";")
);
```
