...

View Full Version : Regex Help... Again :(



Snetty
01-17-2008, 05:40 PM
I've used that title before according to my browser.. i have to say i'm not surprised, it's my total nemesis.

Anyway, onto my problem. I have to find out the total number of pages on a website, via regex.

So far I've come up with the following code




if(preg_match("bytransfer\.php\?sltByCap=V&TransferType=GB&sltTransferred=0&sltCapPercent=&Find=Yes&hdnPage=([:digit:])'", $html, $matches)){

sort($match);
$total_pages = $match[count($match)];
echo $total_pages . " pages";

} else {

echo " - pregmatch didn't work";

}


Predictably it gives me a


Warning: preg_match(): Delimiter must not be alphanumeric or backslash in

error message. Could someone tell me where I'm going wrong please, I'd be most grateful.

Mwnciau
01-17-2008, 05:45 PM
You have to have a starting and ending character, such as # or ~


"#bytransfer\.php\?sltByCap=V&TransferType=GB&sltTransferred=0&sltCapPercent=&Find=Yes&hdnPage=([:digit:])'#"

oesxyl
01-17-2008, 05:52 PM
Predictably it gives me a

error message. Could someone tell me where I'm going wrong please, I'd be most grateful.

I don't if this work, but as first step to fix you miss a '/' at the begining of the regex and one at the end.



if(preg_match("/bytransfer\.php\?sltByCap=V&TransferType=GB&sltTransferred=0&sltCapPercent=&Find=Yes&hdnPage=([:digit:])/'", $html, $matches)){


best regards

StupidRalph
01-17-2008, 06:12 PM
And this might help you defeat your nemesis just yet....
http://www.phpvideotutorials.com/regex

Snetty
01-18-2008, 12:23 PM
thanks alot guys, I got it working without the tutorial but watched it anyway. I'm not going to be premature and say i've defeated that nemesis, but he's certainly running scared :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum