Replace substring of NSAttributedString with another NSAttributedString

Convert your attributed string into an instance of NSMutableAttributedString. The mutable attributed string has a mutableString property. According to the documentation: “The receiver tracks changes to this string and keeps its attribute mappings up to date.” So you can use the resulting mutable string to execute the replacement with replaceOccurrencesOfString:withString:options:range:.

JavaScript replace \n with [duplicate]

You need the /g for global matching replace(/\n/g, “<br />”); This works for me for \n – see this answer if you might have \r\n NOTE: The dupe is the most complete answer for any combination of \r\n, \r or \n var messagetoSend = document.getElementById(‘x’).value.replace(/\n/g, “<br />”); console.log(messagetoSend); <textarea id=”x” rows=”9″> Line 1 Line 2 … Read more

Speed up multiple replacement

For a start don’t specify all those properties over and over again. Unless you change them they don’t change. With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = False .MatchFuzzy = False For loop … Read more

python-pptx – How to replace keyword across multiple runs?

As one can find in python-pptx’s documentation at https://python-pptx.readthedocs.io/en/latest/api/text.html a text frame is made up of paragraphs and a paragraph is made up of runs and specifies a font configuration that is used as the default for it’s runs. runs specify part of the paragraph’s text with a certain font configuration – possibly different from … Read more