Login
|
Signup
langref.org
-
groovy
add..
all
clojure
cpp
csharp
erlang
fantom
fsharp
go
haskell
java
ocaml
perl
php
python
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Regex
Replacing
Replace all regex matches in a string with a dynamic string
Transform
"The {Quick} Brown {Fox}"
into
"The kciuQ Brown xoF"
by reversing words in braces using the regex
/\{(\w+)\}/
.
groovy
replaced = "The {Quick} Brown {Fox}".replaceAll(/\{(\w+)\}/, { full, word -> word.reverse() } )
replaced = "The {Quick} Brown {Fox}".replaceAll(/\{(\w+)\}/, { full, word -> word.reverse() } )
assert replaced=='The kciuQ Brown xoF'
Submit a new solution for
groovy
There are 14 other solutions in
additional
languages (
clojure
,
cpp
,
erlang
,
fantom
...)