Here's what I have so far:
preg_match('/[q|p]=(.*?)&/',$url,$query);
The problem is that if there's a param that ends with a q or p, the it will include those:
&cap=queryhere
since cap ends with p it includes those, how can I only include search queries that come from q's and p's only. Thanks!