Hi again, I am not sure, that it is the clearest way, how to do it, but I've tried this:
<? $query="(4536,'golf tournament management',430,,,,0,0), (1434,'Premium golf balls',,,,,,,,0),"; while (eregi(',\s*,',$query)): $query = preg_replace('/,\s*,/',',NULL,', $query, -1); endwhile; echo $query; ?> As you can see, I've added more ","s to your string to try, if it works good and it seems, that yes... PJ "Craig" <[EMAIL PROTECTED]> píse v diskusním príspevku news:[EMAIL PROTECTED] > Hi, > > I have a text file that I have to parse and insert into a db. > these are a couple of sample lines (they are part of the > variable $query) > > (4536,'golf tournament management',430,0,0), > (1434,'Premium golf balls',,,0), > > I have to replace the blank entries (,,) with NULLs, > and I am using this regex: > $query = preg_replace('/,\s*,/',',NULL,', $query, -1); > > after this line, only ONE of the ,, sets is replaced > by ,NULL, like this: > (4536,'golf tournament management',430,0,0), > (1434,'Premium golf balls',NULL,,0), > > So, my problem is that I have to run the regex twice to > replace both sets of ,, with ,NULL, and I really don't > want to do that. Why isn't it getting them both with the > first regex, and how should I modify it to catch them > both? > > TIA, > Craig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php