0

I want to match the Following URLS to

http://deploy.local/user/12 => fnmatch(PATTERN???, $url);
http://deploy.local/user/tree => fnmatch(PATTERN???, $url);

But

fnmatch("user/[0-9]+" , $url);

does not work with these..

Any Suggestions ?

tereško
  • 58,060
  • 25
  • 98
  • 150

1 Answers1

1

Assuming that you meant by matching, you meant matching the whole URL, then the following regular expression should do the trick:

^https?:\/\/[a-zA-Z]+\.[a-zA-Z]+\/user\/[a-zA-Z0-9]+$

I also made you a permalink at rubular, containing the regex:

http://rubular.com/r/g27NI0bHfI

Kamuffel
  • 592
  • 1
  • 6
  • 17