vestaxpdx Posted June 13, 2012 Share Posted June 13, 2012 Hi, I have this string $my_string = "AND country='United Kingdom' OR country='France' OR country='Spain'"; I simply want to return the counties, so grab everything inside country=' ... ' I just cant figure out the reg expression. Sorry if this is mega easy. I would really appreciate some help. My code so far is: $my_string = "AND country='United Kingdom' OR country='France' OR country='Spain'"; $pattern = ""; preg_match($pattern, $my_string, $matches); print_r($matches); Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted June 13, 2012 Share Posted June 13, 2012 $my_string = "AND country='United Kingdom' OR country='France' OR country='Spain'"; preg_match_all("/country\s*=\s*'([^']+)'/", $my_string, $foo); $countries = $foo[1]; print_r($countries); -Dan Quote Link to comment Share on other sites More sharing options...
vestaxpdx Posted June 13, 2012 Author Share Posted June 13, 2012 Wow thanks a million! Why are they so confusing haha Thanks again! Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted June 13, 2012 Share Posted June 13, 2012 Regular expressions are an entirely different language. It's as confusing as learning python. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.