---
title: "substring(with:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/stringprotocol/substring(with:)"
---

# substring(with:)

Returns a string object containing the characters of the String that lie within a given range.

## Declaration

```swift
func substring(with aRange: Range<Self.Index>) -> String
```
