<?php $str = 'SELECT * from `foo` WHERE `foo_id` > 0 LIMIT 5'; $regex = '/ (?P<more1>.*?) (?:WHERE\s+ (?P<where>(?:.(?!GROUP BY|HAVING|ORDER BY|LIMIT))+) )? # removing the ? will capture (?P<more2>.*) /imsx'; \preg_match($regex, $str, $matches); var_dump($matches);
You have javascript disabled. You will not be able to edit any code.