Page 1 of 1

Mmm

Posted: Sat Jun 24, 2006 7:54 pm
by lizzardnub
Ok, so now that I was shown how to run the search against the text file, I'm left with php output:

[13.249.161.18] 23-06-2006 05:10 [localhost] installed blahblah crap on [8.46.176.244] 23-06-2006 05:10 [localhost] logged in to [8.46.176.244]

instead of nice orderly [ip.ip.ip.ip], [localhost], [ip.ip.ip,ip]. After reading up on it a bit I'm assuming this because search strings are inherently greedy. I tried using the >U PCRE modifier I read about at http://www.pcworld.idg.com.au
like so

Code: Select all

$pat = "<\[.*\]>U";
but no joy. So this is where I stand

Code: Select all

<? 
$str = file_get_contents( "log/log.txt");
$pat = "\[.*\]";
$regs = array();
if(ereg($pat,$str,$regs))
{ 
echo "match: {$regs[0]}\n"; 
} 
?>


The end goal of this little project is to extract a bunch of IP's that are enclosed in brackets out of a text file and put them into a mysql database. I'm hoping to get only one instance of each IP address with the duplicates in the .txt file incrementing some sort of counter next to the IP.

Posted: Sat Jun 24, 2006 7:57 pm
by John Cartwright
#1 Please use more descriptive titles.. "mmm" tells me nothing
#2 Why did you start another thread?
#3 Start using [syntax=php][/syntax] tags please.

Topic Locked.