This language bar is your friend. Select your favorite languages!

Idiom #116 Remove occurrences of word from string

Remove all occurrences of string w from string s1, and store the result in s2.

s2 = s1.replace(w, '')
string s2 = s1.Replace(w, string.Empty);
import std.array;
auto s2 = s1.replace(w, "");
1
import "strings"
s2 := strings.Replace(s1, w, "", -1)
import Data.List (isPrefixOf)
remove :: String -> String -> String
remove w "" = ""
remove w s(c:cs) 
  | w `isPrefixOf` s = remove w (drop (length w) s)
  | otherwise = c : remove w cs

s2 = remove w s1
var s2 = s1.replace(w, '');
String s2 = s1.replace(w, "");
s2 = s1:gsub(w,"")
$s2 = str_replace($w, '', $s1);
uses Sysutils;
s2 := s1.Replace(w,''.Empty);
uses Sysutils;
s2 := s1.Replace(w,'');
Uses sysutils;
s2 := stringreplace(s1, w, '', [rfReplaceAll]);
my $regex = quotemeta($w);
my $s2 = $s1;
$s2 =~ s/$regex//g;
s2 = s1.gsub(w, "")
s2 = s1.replace(w, "");

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org