1

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?

Jayyrus
  • 12,961
  • 41
  • 132
  • 214

2 Answers2

0

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.

HamZa
  • 14,671
  • 11
  • 54
  • 75
  • it works if the string is in the format "string-string". if the string is in the form "string -string" it doesn't work.. i need something that can take every string – Jayyrus Jul 03 '13 at 12:12
  • @JackTurky Please be precise. Regex isn't a guess game. You have provided an example where there isn't a space. I will edit the regex for now. – HamZa Jul 03 '13 at 12:15
  • @JackTurky Oh and if you want to match *everything* then just use `.*`, but I doubt that you want that ... – HamZa Jul 03 '13 at 12:17
0

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

/city/(\S+)
Krishna
  • 381
  • 2
  • 9