I see, I miusunderstood, read too quickly, and thought you simply wanted
to split at the comma. The suggestion that you use exlode(',',2) makes
sense to me. You could do the same with
preg_split ($pattern, $string, 2)
Or for a more complex regex, there's preg_match, which puts the results
in an array of matches. That would to me seem the more logical choice
if you want to save parenthesized data. But I'm an old Perl programmer
and there we don't have the extras that PHP gives to preg_split. So, in
Perl it's split() for splitting and m// for matching. Perhaps in
programming as in art, less is more.
Cheers,
Myron
Google Kreme wrote:
2. Why do you need this complex expression to split at a comma? This
'/,/' would do the trick. And even simpler
explode(',', $line);
Because I need to split only at the FIRST comma.
Also your regex ^([^,]+) asks the perl regex parser to find the
beginning of a line at which there is one or more instances of NO
Comma. That is, [^ ] is a negation, so that [^0-9] means do not match
any numbers.
Yes, and ^([^,]+) means, From the start of the line, get 1 or more
characters that are not a comma and put them in \01.
--
_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php