Epiphany regex-route error

549 Views Asked by At

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?

2

There are 2 best solutions below

3
On BEST ANSWER

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.

0
On

Try This Regex it will work as url doesnot contain space...

/city/(\S+)