IT Community - Software Programming, Web Development and Technical Support

regex (yuck)

This is a discussion on regex (yuck) within the PHP Programming forums, part of the Web Development category; ok so i have this script that displays the content of a webpage PHP Code: PHP Code: <?php $...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-24-2007, 01:04 AM
pranky pranky is offline
D-Web Programmer
 
Join Date: Feb 2007
Posts: 51
pranky is on a distinguished road
Default regex (yuck)

ok so i have this script that displays the content of a webpage
PHP Code:
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 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 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!!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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



All times are GMT -7. The time now is 05:15 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0