Parsing simple data field
Posted: Tue Mar 20, 2007 3:27 pm
So far I have this regex constructed:
The (23) is optional and may *not* always be in existence whereas the the name is always there...
I need the output to always be two array elements:
Is this possible, what am i doing wrong in the regex? Am I passing the wrong constant?
Thanks
Code: Select all
$line = 'NAME(23): John Smith';
$data = preg_split('/NAME(\(d\))*: (.)+/', $line, -1, PREG_SPLIT_OFFSET_CAPTURE);I need the output to always be two array elements:
Code: Select all
$data[0] = 23; // Optional number may not exist but this field should always be set NULL or not
$data[1] = "John Smith"Thanks