<?php $text="http://www.google.ru/search?hl=ru&source=hp&q=antichat.ru&btnG=%D0%9F%D0%BE%D0%B8%D1%81%D0%BA+%D0%B2+Google&lr=&aq=f&oq="; preg_match('/q=(.*)&btnG/',$text,$m); echo $m[1]; ?>