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

# replace(with:value:)

Replaces an attribute with a different attribute that a key path identifies.

## Declaration

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

## Parameters

- `keyPath`: The key path that identifies the new attribute.
- `value`: The value of the new attribute.

## See Also

### Replacing Attributes

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