---
title: "replacingAttributes(_:with:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/attributedstringprotocol/replacingattributes(_:with:)"
---

# replacingAttributes(_:with:)

Returns an attributed string by replacing occurrences of attributes in one attribute container with those in another attribute container.

## Declaration

```swift
func replacingAttributes(_ attributes: AttributeContainer, with others: AttributeContainer) -> AttributedString
```

## Parameters

- `attributes`: The existing attributes to replace.
- `others`: The new attributes to apply.

## Return Value

Return Value An attributed string created by replacing occurrences of attributes in one attribute container with those in another attribute container.

## See Also

### Applying Attributes

- [settingAttributes(_:)](foundation/attributedstringprotocol/settingattributes(_:).md)
- [mergingAttributes(_:mergePolicy:)](foundation/attributedstringprotocol/mergingattributes(_:mergepolicy:).md)
- [AttributedString.AttributeMergePolicy](foundation/attributedstring/attributemergepolicy.md)
