RE: Regex Lookbehind help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alex Hogan wrote:
>> I just tried this out and the first regex is actually working for me
>> on php 4.3.8 (cli).  Can you post some code?
>
> At this point all I'm trying to do is print the array with the
> addresses.
>
> $file                =    readfile('mypathto/myfile.html');
> $patrn             =
> (\w[-._\w]*\w(?<!webmaster)@\w[-._\w]*\w\.\w{2,3});
>
> $addresses     =    preg_match($patrn,$file);
>
> print_r($addresses);

Check the documentation for preg_match()...it can't be used that way.  It returns
false or the number of matches, but not the matching text itself.  To get the
matches you have to supply the third parameter (matches).  Plus you'll probably want
to use preg_match_all() unless you only want to get the first match.

Also, I don't believe readfile() is what you want.  It looks like
file_get_contents() is more in line with what you are trying to do.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux