<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/AttributedString/subscript(_:)-2yypq",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Subscript",
  "symbol" : {
    "kind" : "Instance Subscript",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation16AttributedStringV7SwiftUIEyAA013DiscontiguousB9SubstringVAD0B13TextSelectionVcip"
  },
  "title" : "subscript(_:)"
}
-->

# subscript(_:)

Obtain the discontiguous substring of a selection.

```
subscript(selection: AttributedTextSelection) -> DiscontiguousAttributedSubstring { get }
```

## Overview

In the case of an insertion point, this substring is empty. Otherwise,
the substring contains all selected characters.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)