---
title: "replace(with:value:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/attributedstring/singleattributetransformer/replace(with:value:)-6bn0e"
---

# replace(with:value:)

Replaces an attribute with a different attribute.

## Declaration

```swift
@preconcurrency mutating func replace<U>(with key: U.Type, value: U.Value) where U : AttributedStringKey, U.Value : Sendable
```

## Parameters

- `key`: The key of the new attribute.
- `value`: The value of the new attribute.

## See Also

### Replacing Attributes

- [replace(with:value:)](foundation/attributedstring/singleattributetransformer/replace(with:value:)-xg8b.md)
