# strpos {#strpos}

**Parent topic:**[Functions](../../Functions/category.md)

## Syntax {#syntax}

`strpos(X, str)`

## Arguments {#arguments}

**X** is a string scalar/vector.

**str** is a string scalar.

## Details {#details}

If *X* contains str, return the index in *X* where the first occurrence of str starts; otherwise, return -1.

## Examples {#examples}

```
strpos("abcdefg","cd");
// output: 2

strpos("abcdefg","d");
// output: 3

strpos("abcdefg","ah");
// output: -1
```

