Thread: regex (yuck)
View Single Post
  #1 (permalink)  
Old 08-04-2006, 08:57 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,569
Last Blog:
Tidy up your HTML
Credits: 0
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default regex (yuck)

ok so i have this script that displays the content of a webpage
PHP Code:
<?php
$url 
"https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065";

//Gets the content of the submited URL;
$content file_get_contents($url); 

//Strips the tags of the $content;
$strip strip_tags($content);

//Removes Everything in the up to For:;
$remove stristr($strip'Hawk Down');

//Declares $remove as $getstats;
$stats $remove;
echo 
$stats;
?>
what i want to do is parse the name Ozymandias from the $stats string. While trying to build my regex i used a pseudo-code so i could avoide the long load of getting the actual content of the website. The psuedo code is below:
PHP Code:
<?php
$string 
'Down Ozymandias. Rank: 1-Star General ( 14 ) PCID: A13-3E71AC Player Created: June 9, 2006 TABLE.statsx ';
preg_match('#Down (.*?) Rank#'$string$matches);
$str $matches[1];
echo 
$str;
?>
the $string is a word for word exerpt from the $stats string in the first code. So i figured I could use $string to test out my regex and when i get it to work just replace the static $string with the dynamic string ($stats). The regex above works fine with the static string but when i encorperated it into the larger script it does not work.

PHP Code:
<?php
$url 
"https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065";

//Gets the content of the submited URL;
$content file_get_contents($url); 

//Strips the tags of the $content;
$strip strip_tags($content);

//Removes Everything in the up to For:;
$remove stristr($strip'Hawk Down');

//Declares $remove as $getstats;
$stats $remove;

preg_match('#Down (.*?) Rank#'$stats$matches);
$str $matches[1];
echo 
$str;

?>
i have no idea what to do. this is the only thing stoping me from progresing with my program and its a pain! any help is appreciated.

thank you!!

Last edited by John; 08-04-2006 at 09:33 PM. Reason: adf
Reply With Quote

Sponsored Links