DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
Quick Search:  
Register Now! Welcome to Dnforum.com You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us.
Go Back   DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars > Content Development > Website Development and Design Discussion > Coding/Programming/Languages
Register Domains for $6.99 - GoDaddy.com
Reply
 
LinkBack Thread Tools Display Modes
Old 04-28-2008, 10:57 PM   #1 (permalink)
Platinum Lifetime Member
 
SGBoise's Avatar
 
Last Online: Yesterday 02:37 AM
iTrader: (1)
Join Date: Jan 2008
Posts: 10
DNF$: 60
Location: USA


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]/category/3/pictures45.html[/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
__________________
GamePacks.org - Products for the Arcade/Media Community
TopMediaScript com - The ultimate media site script
AutoVideoScript com - Run your own youtube sharing site
SGBoise is offline   Reply With Quote
Old 05-02-2008, 01:11 AM   #2 (permalink)
Platinum Lifetime Member
 
xrvel's Avatar
 
Name: Kurniawan
Last Online: 05-05-2008 06:34 AM
iTrader: (0)
Join Date: Nov 2007
Posts: 10
DNF$: 330
Location: Indonesia
Country:


Try this
PHP Code:
<?php
$url 
'/category/3/pictures45.html';

preg_match('/\/category\/([0-9]+)\/([a-z]+)([0-9]+)/i'$url$match);
echo(
'<pre>' print_r($matchtrue) . '</pre>');

$id $match[1];
$pagenumber $match[3];

echo (
'<p> ID = ' $id '</p>');
echo (
'<p> Page number = ' $pagenumber '</p>');
?>
xrvel is offline   Reply With Quote
Old 05-02-2008, 11:07 AM   #3 (permalink)
Platinum Lifetime Member
 
SGBoise's Avatar
 
Last Online: Yesterday 02:37 AM
iTrader: (1)
Join Date: Jan 2008
Posts: 10
DNF$: 60
Location: USA


You are awesome. Thanks.
__________________
GamePacks.org - Products for the Arcade/Media Community
TopMediaScript com - The ultimate media site script
AutoVideoScript com - Run your own youtube sharing site
SGBoise is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 11:10 PM.
Copyright @2001-2008 DNForum.com