* John Weez ([EMAIL PROTECTED]) [Dec 30. 2001 03:23]:

> I have a small program which captures the output of a webpage and puts the
> data in to a string variable.
> I then use teh strip tags function of php to clean it up a bit.

> then i want to use regular expressions to extract all the numbers from the
> page ..they are like this usually numbers.numbers (IE: 40.40 ).

> For some reason my expressions are not matching anything in the string
> unless i type exactly what i am looking for... could the fact that there
> are line reurns in the string be causing a problem? or do i need to
> somehow tell php to goto the next line?

How are you grabbing all the data from the page?

> I had an older version of the program which saved teh data to a file and
> then PhP scanned the file line by line..this worked...but i'm trying to
> make a more elegant solution that won;t kill my hard drive faster ;)

It's going to use a bit of memory to search an entire page with a
regular expression. It's probably going to be slow(er) no matter how you
slice it.

I would use the PCRE functions; preg_match_all() probably..

Look over these:
<http://www.php.net/manual/en/pcre.pattern.modifiers.php> 

I think you'll want to use m (and g is default, as the comment says).

Something like this may work:

<?php

/* untested */
preg_match_all('/([0-9]+\.[0-9]+)/m',$string,$matches);

while(list(,$match) = each($matches[0])) 
{
   print "$match\n";
}

?>

-- 
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
Recursive: Adj. See Recursive.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to