General RegEx Pattern Help

Hey guys, this is my first post being brand new to the forums here. My apologies if I am in the wrong section.

I need help creating a simple regex pattern to store 5 IPs into 5 different variables. I think I need to use “preg_split” but I don’t know where to begin.

Here is an example of my file to be parsed.

1/27/2013 6:31:10 AM Removed        <>
1/27/2013 6:31:17 AM Added          <>
1/27/2013 6:31:18 AM Removed        <>
1/27/2013 6:31:25 AM Added          <>
1/27/2013 6:31:26 AM Removed        <>

Thanks in advance!

Do you need only the IP address?

You would need to read the file line by line (see file() function)

Then you can match the IP address from each line. For example:

$str = “1/27/2013 6:31:10 AM Removed <>”;
if (preg_match(’/<(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})>/’, $str, $parts)) {


array (size=2)
  0 => string '<>' (length=16)
  1 => string '' (length=14)
Sponsor our Newsletter | Privacy Policy | Terms of Service