---
title: "index(before:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/string/index(before:)"
---

# index(before:)

Returns the position immediately before the given index.

## Declaration

```swift
func index(before i: String.Index) -> String.Index
```

## Parameters

- `i`: A valid index of the collection. i must be greater than startIndex.

## Return Value

Return Value The index value immediately before i.

## See Also

### Manipulating Indices

- [startIndex](swift/string/startindex.md)
- [endIndex](swift/string/endindex.md)
- [index(after:)](swift/string/index(after:).md)
- [formIndex(after:)](swift/string/formindex(after:).md)
- [formIndex(before:)](swift/string/formindex(before:).md)
- [index(_:offsetBy:)](swift/string/index(_:offsetby:).md)
- [index(_:offsetBy:limitedBy:)](swift/string/index(_:offsetby:limitedby:).md)
- [formIndex(_:offsetBy:)](swift/string/formindex(_:offsetby:).md)
- [formIndex(_:offsetBy:limitedBy:)](swift/string/formindex(_:offsetby:limitedby:).md)
- [distance(from:to:)](swift/string/distance(from:to:).md)
- [indices](swift/string/indices-swift.property.md)
