Login
|
Signup
langref.org
-
php
add..
all
clojure
cpp
csharp
erlang
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
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+)\}/
.
php
// We have to use the e-modifier
preg_replace("/\{(\w+)\}/e", "''.strrev('\\1').''", "The {Quick} Brown {Fox}");
<?php
// We have to use the e-modifier
preg_replace("/\{(\w+)\}/e", "''.strrev('\\1').''", "The {Quick} Brown {Fox}");
?>
Submit a new solution for
php
There are 14 other solutions in
additional
languages (
clojure
,
cpp
,
erlang
,
fantom
...)