Re: [PHP] Re: preg_split

2006-11-03 Thread Google Kreme
On 03 Nov 2006, at 15:56 , Stut wrote: Google Kreme wrote: On 03 Nov 2006, at 12:32 , Myron Turner 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 com

Re: [PHP] Re: preg_split

2006-11-03 Thread Myron Turner
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

Re: [PHP] Re: preg_split

2006-11-03 Thread Stut
Google Kreme wrote: > On 03 Nov 2006, at 12:32 , Myron Turner 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. explode(',', $line, 2);

Re: [PHP] Re: preg_split

2006-11-03 Thread Google Kreme
On 03 Nov 2006, at 12:32 , Myron Turner wrote: 1. A preg_ expression has to have the delimeters '/^([^,]+),\s?(.*)/'. Ah, well, that would make a difference. $cid[$i]=preg_split('/^([^,]+),\s?(.*)/', $l

[PHP] Re: preg_split

2006-11-03 Thread Myron Turner
1. A preg_ expression has to have the delimeters '/^([^,]+),\s?(.*)/'. 2. Why do you need this complex expression to split at a comma? This '/,/' would do the trick. And even simpler explode(',', $line); Also your regex ^([^,]+) asks the perl regex parser to find the beginnin

Re: [PHP] Re: preg_split problem

2002-11-09 Thread Ernest E Vogelsinger
At 18:59 09.11.2002, samug said: [snip] >Thanks. >But what if you don't know how many elements there will be ahead? > >"Samug" <[EMAIL PROTECTED]> kirjoitti viestissä >news:20021109165530.58233.qmail@;pb1.pair.com... >> Could someone tell me why isn't this wo

Re: [PHP] Re: preg_split problem

2002-11-09 Thread Marek Kilimajer
if you use list($one,$two,$three,$rest) = preg_split("/\s+/", $text, *4*); you get the remaining elements in $rest as a single string samug wrote: Thanks. But what if you don't know how many elements there will be ahead? "Samug" <[EMAIL PROTECTED]> kirjoitti viestissä [EMAIL PROTECTED]">news:[E

[PHP] Re: preg_split problem

2002-11-09 Thread samug
Thanks. But what if you don't know how many elements there will be ahead? "Samug" <[EMAIL PROTECTED]> kirjoitti viestissä news:20021109165530.58233.qmail@;pb1.pair.com... > Could someone tell me why isn't this working? > > $text = "And what did I tell you?"; > list($one,$two,$three,$rest) = preg_s