Swifterswift: Add replacingOccurrences extension to NSAttributedString

Created on 27 Nov 2017  路  7Comments  路  Source: SwifterSwift/SwifterSwift

Add replacingOccurrences method to NSAttributedString to replace occurrences of a string with another string, like String has:

replacingOccurrences(of: StringProtocol, with: StringProtocol)
good first issue help wanted new extension

Most helpful comment

I think this extension should be on NSMutableAttributedString (if it isn't already) and not NSAttributedString.

All 7 comments

~It would be even better to post an answer with the extension to this Stackoverflow thread as well :)~

@omaralbeik Stackoverflow thread link points to non existing page (404).

@Najdan, it looks like the question was removed 馃槥. anyway, it was a thread where someone asked the same question above :)

I think this extension should be on NSMutableAttributedString (if it isn't already) and not NSAttributedString.

@SD10, you are correct NSMutableAttributedString already contains method replaceOccurrences(of:with:options:range:).

replace occurrences test

Thanks @Najdan 馃憤

Thank you guys 馃挴

Was this page helpful?
0 / 5 - 0 ratings