Here's the updated version of the PHP code. Note that it's quickly put together so it might not be the best solution but it works for now. I'm only splitting the text for you. How you process it later is up to you -)
For your reference, this is roughly what happens in the regex:
^ -> Start at the beginning of line
([\s])+) -> Grab 1 or more non-space characters and store it in placeholder 1 (note the () )
\s+ -> Grab 1 or more whitespace characters
([^\s]+) -> Grab 1 or more non-space characters and store it in placeholder 2
(.*?)\s+ -> Grab any characters before encountering a whitespace. Note the ?, which is a limiter. Place the 'any characters' in placeholder 3. Then grab 1 or more whitespace characters
(Servlet.Engine.Transports : \d+) -> Grab the Servlet.(etc) and then one or more digits, then store it in placeholder 4. Note that I used a single space around the : sign, but if it can be any type of whitespace, substitute it with \s+ as before.
\s+ -> Grab 1 or more whitespace
(.*) -> Grab 1 or more any characters and store it in placeholder 5.
$ -> Denotes the end of line.
The i at the end is for case insensitive matching. I put it there just to be safe.
Hope it helps.
-stndn.
PHP:
<?php
# Note: I modified some of the texts for testing purpose (the 1-3 digits after Transports part)
$myText[] = '06/07/07 02:44:28.917 INFO Servlet.Engine.Transports : 0 <FBIBLVI>';
$myText[] = '06/07/07 02:44:28.918 INFO Servlet.Engine.Transports : 01 <client_group_id>xxxxxxxxxx</client_group_id>';
$myText[] = '06/07/07 02:44:28.918 INFO Servlet.Engine.Transports : 04 <portal_id>xxxxxxxxxx</portal_id>';
$myText[] = '06/07/07 02:44:28.919 INFO Servlet.Engine.Transports : 098 <incl_rules_table>N</incl_rules_table>';
$myText[] = '06/07/07 02:44:27.585 INFO Servlet.Engine.Transports : 088 Type: TEST';
$myText[] = '06/07/07 02:44:27.586 INFO Servlet.Engine.Transports : 013 Site User: QA_BPORTAL';
$myText[] = '06/07/07 02:44:27.588 INFO Servlet.Engine.Transports : 0 Retrieving user ent list';
$myText[] = '06/07/07 02:44:27.619 INFO Servlet.Engine.Transports : 01 Retrieve ent names for user: 3771000016, contract: qa_bportal';
foreach ($myText as $val)
{
preg_match ('/^([^\s]+)\s+([^\s]+)\s+(.*?)\s+(Servlet.Engine.Transports : \d+)\s+(.*)$/i', $val, $myResult);
print_r ($myResult);
}
?>
For your reference, this is roughly what happens in the regex:
^ -> Start at the beginning of line
([\s])+) -> Grab 1 or more non-space characters and store it in placeholder 1 (note the () )
\s+ -> Grab 1 or more whitespace characters
([^\s]+) -> Grab 1 or more non-space characters and store it in placeholder 2
(.*?)\s+ -> Grab any characters before encountering a whitespace. Note the ?, which is a limiter. Place the 'any characters' in placeholder 3. Then grab 1 or more whitespace characters
(Servlet.Engine.Transports : \d+) -> Grab the Servlet.(etc) and then one or more digits, then store it in placeholder 4. Note that I used a single space around the : sign, but if it can be any type of whitespace, substitute it with \s+ as before.
\s+ -> Grab 1 or more whitespace
(.*) -> Grab 1 or more any characters and store it in placeholder 5.
$ -> Denotes the end of line.
The i at the end is for case insensitive matching. I put it there just to be safe.
Hope it helps.
-stndn.