Rgular Expression - 1st alternative

From: Date: Thu, 09 Oct 2003 17:54:09 +0000
Subject: Rgular Expression - 1st alternative
Groups: php.general 
Request: Send a blank email to php-general+get-165652@lists.php.net to get a copy of this message
Hi all. I've got one problem with %subj%. I need to get 1st appearance of any alternative pattern, but my regexp get last. in $out[2] (input) is "columns FROM tables WHERE conditions ORDER BY sth DESC LIMIT 1 OFFEST 0" preg_match("/[[:space:]]*(.*)[[:space:]]+from[[:space:]]+(.*)[[:space:]]+whe re[[:space:]]+(.*)[[:space:]]+(order by|group by|having|limit)(.*)/is", $out[2], $out); This will produce: Array ( [0] => columns FROM tables WHERE conditions ORDER BY sth DESC LIMIT 1 OFFEST 0 [1] => columns [2] => tables [3] => conditions ORDER BY sth DESC // but here I need only "conditions" [4] => LIMIT // and here shloud be ORDER BY sth DESC LIMIT [5] => 1 OFFEST 0 ) I was searchnig web and forums long time, but didn't found working advice. I tried to use '?' and other pieces of regexp pattern, but I can't write functional regexp. Thanx for any advices. Emo

« previous php.general (#165652) next »