i'm trying to implement a Rest web services using epiphany framework in this way:
include_once 'rest/Epi.php';
Epi::setSetting('exceptions', true);
Epi::setPath('base', 'rest');
Epi::init('route');
getRoute()->post('/city/(\w+)', 'getCity');
getRoute()->run();
function getCity($tmp){
//My work
}
The problem borns when i use url like:
http://mydomain/*/city/OLOMOUC-REPUBLICA%20CHECA
what i understood is that the problem is with regex (\w+)
, how can i change it to allow any string?
It seems that the OP wants to match everything. So (.*)
did the job.
\w
is the same as writing [a-zA-Z0-9_]
. Which basically means you should use ([\w\s%-]+)
. \s
will match a whitespace.