Login
|
Signup
langref.org
-
ruby
and
erlang
add..
all
clojure
cpp
csharp
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
php
python
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Regex
Replacing
Replace the first regex match in a string with a static string
Transform
"Red Green Blue"
into
"R*d Green Blue"
by replacing
/e/
with
"*"
ruby
p "Red Green Blue".sub(/e/,'*')
p "Red Green Blue".sub(/e/,'*')
erlang
{ok, Replaced, _} = regexp:sub("Red Green Blue", "e", "*"),
-module(regxsub).
-export([start/0]).
start() ->
{ok, Replaced, _} = regexp:sub("Red Green Blue", "e", "*"),
io:format("~s~n", [Replaced]).
erlang
12B3+
re:replace("Red Green Blue", "e", "*", [{return, list}]).
re:replace("Red Green Blue", "e", "*", [{return, list}]).
Submit a new solution for
ruby
or
erlang
There are 12 other solutions in
additional
languages (
clojure
,
cpp
,
fantom
,
fsharp
...)