Michael T. Peterson wrote:
I need to find all lines that begin with the string 'WAZ' after reading from a url (http://www.atmos.washington.edu/data/zone_report.KSEW.html). While I've tried every combination of expressions under the sun (using the functions preg_match(), ereg()), I can not figure out a correct regexp for this task.
This works. Read the entire file into a string (file_get_contents() works great here) and pass to this regex. $matches[0] will have your lines that start with WAZ. Example:
<?php
$file = "asdf asdf asdf WAZ this is line 1 asdf asdf asdf asdf WAZ this is another line that should be matches fWAZ this is a line that shouldn't be matches WAZ one more for good measure and a bad one WAZ (whoa, who put that there!) asdf asdf asd fas df asdf";
preg_match_all('/^WAZ.*/m',$file,$matches);
print_r($matches[0]);
?>
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php