Add replacingOccurrences method to NSAttributedString to replace occurrences of a string with another string, like String has:
replacingOccurrences(of: StringProtocol, with: StringProtocol)
~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:).

Thanks @Najdan 馃憤
Thank you guys 馃挴
Most helpful comment
I think this extension should be on
NSMutableAttributedString(if it isn't already) and notNSAttributedString.