Replace CRLF using powershell

This is a state-of-the-union answer as of Windows PowerShell v5.1 / PowerShell Core v6.2.0: Andrew Savinykh’s ill-fated answer, despite being the accepted one, is, as of this writing, fundamentally flawed (I do hope it gets fixed – there’s enough information in the comments – and in the edit history – to do so). Ansgar Wiecher’s … Read more

JavaScript/jQuery: replace part of string?

You need to set the text after the replace call: $(‘.element span’).each(function() { console.log($(this).text()); var text = $(this).text().replace(‘N/A, ‘, ”); $(this).text(text); }); <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script> <div class=”element”> <span>N/A, Category</span> </div> Here’s another cool way you can do it (hat tip @Felix King): $(“.element span”).text(function(index, text) { return text.replace(“N/A, “, “”); });

Replace multiple characters in a string in Objective-C?

A somewhat inefficient way of doing this: NSString *s = @”foo/bar:baz.foo”; NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@”/:.”]; s = [[s componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @””]; NSLog(@”%@”, s); // => foobarbazfoo Look at NSScanner and -[NSString rangeOfCharacterFromSet: …] if you want to do this a bit more efficiently.