Merlin wrote:
Hi there,

I want to filter out ip adresses out of a given text string. They are inside a logfile and values are seperated by tabs. I tryed sub_str which works fine if you know the length of the characters. In case of the ip adress this is not the case, since they are sometimes shorter than others.
Has anybody an idea how to filter the ip adress out? Maybe magically with any regex or somehow with tab recognicion.


This is an example of parts of the text
20:03:20        [MSG]   192.168.0.129  bla bla


Given:

<?php
  $string=sprintf("20:03:20\t[MSG]\t192.168.0.129\tbla bla");
  print_r(explode("\t",$string));
?>

Output is :
Array
(
    [0] => 20:03:20
    [1] => [MSG]
    [2] => 192.168.0.129
    [3] => bla bla
)

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



Reply via email to