NamePros.Com (http://www.namepros.com/)
-   Programming (http://www.namepros.com/programming/)
-   -   Can't get regex to match properly (http://www.namepros.com/programming/463191-cant-get-regex-to-match-properly.html)

SGBoise 04-28-2008 07:48 PM

Can't get regex to match properly
 
I am trying to match this uri. Also I want 3 to match as id and 45 in pictures45.html as pagenumber.
HTML Code:
/category/3/pictures45.html


With this regex I got to match the category and id.
PHP Code:
preg_match("/^\/category\/(?P<id>\d+)/", $url, $matches);


With this regex I got to match the pagenumber.
PHP Code:
preg_match("/(?P<pagenumber>\d).html/", $url, $matches);


I figured I can combine both the regex and it should work but I can't get it to work.
PHP Code:
preg_match("/^\/category\/(?P<id>\d+)(?P<pagenumber>\d).html/", $url, $matches);


What am I doing wrong?

Thanks guys

DylanButler 04-28-2008 09:44 PM

This one worked for me:

/category/([0-9]+)/pictures([0-9]+).html

SGBoise 04-29-2008 11:50 AM

Originally Posted by DylanButler
This one worked for me:

/category/([0-9]+)/pictures([0-9]+).html



Thanks buddy.


All times are GMT -7. The time now is 06:47 PM.
Site Sponsors
Advertise your business at NamePros

Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0