View Problem

Replace all regex matches in a string with a static string

Transform "She sells sea shells" into "She X X shells" by replacing /se\w+/ with "X"
ExpandDiskEdit
java
String replaced = text.replaceAll("se\\w+", "X");
ExpandDiskEdit
erlang
% Erlang uses 'egrep'-compatible regular expressions, so shortcuts like '\w' not supported
{ok, Replaced, _} = regexp:gsub("She sells sea shells", "se[A-Za-z0-9_]+", "X"),
DiskEdit
erlang 12B3+
re:replace("She sells sea shells", "se\\w+", "X", [global, {return, list}]).

Submit a new solution for java or erlang
There are 13 other solutions in additional languages (clojure, cpp, csharp, fantom ...)