<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/AttributedString/FormattingOptions/applyReplacementIndexAttribute",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation16AttributedStringV17FormattingOptionsV30applyReplacementIndexAttributeAEvpZ"
  },
  "title" : "applyReplacementIndexAttribute"
}
-->

# applyReplacementIndexAttribute

An option to add an attribute that marks replacements in localized strings.

```
static let applyReplacementIndexAttribute: AttributedString.FormattingOptions
```

## Discussion

When you use this option, string formatting applies the [`replacementIndex`](/documentation/Foundation/NSAttributedString/Key/replacementIndex) key to the final range of each replacement. Its value is an `Int`, wrapping the integer ordinal of that particular replacement, such as the `2` in `%2$@`. This allows the developer to relate ranges to replacements even if a localizer modifies the word order.

---

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)