I am having a 'bad brain' day... What I am trying to do is parse a string and in a situation where I have four spaces followed by an 8 or 10 digit number, I want to replace the spaces with a 'pipe' character, but NOT in a situation where there are 4 spaces and no number...
I have used :
Code:
$SampleData = preg_replace("/(\s{4})/", "|", $Data);
successfully - right up to the point where I have the 4 spaces and no number scenario, but by my logic
Code:
$SampleData = preg_replace("/(\s{4})(\d{8,1})/", "|", $Data);
will not preserve the number.
It all sounds complicated, but I am looking to parse a string containing epoch timestamp and variable length data and separate into an array split on the epoch (or spaces) e.g.
Code:
1182169673 jdegr Affected Services set to DIGITAL Number of Customers Affected set to 326 Assignee Group set to Dispatch Priority set to 1 Ticket Status set to Assigned Outage Start set to 18/06/2007 13:23:04 Region set to UK Short Description set to Loss Equipt - B715 0*. B716 0* 1182169679 jdegr Target Fix Time set to 18/06/2007 17:23:04 1182169715 p2026145 High Priority Owner set to BAR, Foo 1182169764 J2026913 Assignee Name set to BLOGGS, Joe 1182170416 r1006992 Ticket Status set to Accepted Target Fix Time set to 18/06/2007 17:23:04 1182177812 s2024123 Fix Details set to Replaced PSU service now retored Ticket Status set to Restored Outage End set to 18/06/2007 15:40:58 1182177893 s2024123 Actual Fix Date/Time set to 18/06/2007 15:41:00 Finding Code set to RP_POWER_SUPPLY_UNIT_(PSU) Reason Code set to W1_EQUIP_FAIL_NORMAL_END_OF_LIFE Solution Code set to REPLACED 1182177909 s2024123 Fix Details set to Replaced PSU service now restored 1182177922 s2024123 Assignee Group set to 2nd Line Ticket Status set to Fixed 1182177922 s2024123 Assignee Group set to Holding Queue Ticket Status set to Pending Callbacks 1182240543 b2019505 Assignee Group set to 2nd Line Ticket Status set to Fixed 1182240647 p2026145 Ticket Status set to Closed
is parsed to form:
Code:
Array
(
[0] => 1182169673 jdegr Affected Services set to DIGITAL Number of Customers Affected set to 326 Assignee Group set to Dispatch Priority set to 1 Ticket Status set to Assigned Outage Start set to 18/06/2007 13:23:04 Region set to UK Short Description set to Loss Equipt - B715 0*. B716 0*
[1] => 1182169679 jdegr Target Fix Time set to 18/06/2007 17:23:04
[2] => 1182169715 p2026145 High Priority Owner set to BAR, Foo
[3] => 1182169764 J2026913 Assignee Name set to BLOGS, Joe
[4] => 1182170416 r1006992 Ticket Status set to Accepted Target Fix Time set to 18/06/2007 17:23:04
[5] => 1182177812 s2024123 Fix Details set to Replaced PSU service now retored Ticket Status set to Restored Outage End set to 18/06/2007 15:40:58
[6] => 1182177893 s2024123 Actual Fix Date/Time set to 18/06/2007 15:41:00 Finding Code set to RP_POWER_SUPPLY_UNIT_(PSU) Reason Code set to EQUIP_FAIL_NORMAL_END_OF_LIFE Solution Code set to REPLACED
[7] => 1182177909 s2024123 Fix Details set to Replaced PSU service now restored
[8] => 1182177922 s2024123 Assignee Group set to 2nd Line Ticket Status set to Fixed
[9] => 1182177922 s2024123 Assignee Group set to Holding Queue Ticket Status set to Pending Callbacks
[10] => 1182240543 b2019505 Assignee Group set to 2nd Line Ticket Status set to Fixed
[11] => 1182240647 p2026145 Ticket Status set to Closed
)
Hope this makes sense, and I guess there is a very simple solution that I am missing...