I've been banging my head on this one for a while...did a few searches on the web and here at DP forums, but I can't figure out what I'm doing wrong (aside from attempting this with very little knowledge of regex and php). I have a CURL-ed page. There's an option list that I want to parse. Here's a section of code; <option value="employee1.lastname">Superman <option value="firstname.mylastname">Batman Code (markup): I thought something like this would do it: preg_match_all ("/option value=\"[^']*?\"/", $data, $matches); foreach ($matches[0] as $match) { echo $match."<br>"; } Code (markup): But my results end up as: option value="employee1.lastname" option value="firstname.mylastname" I only want to extra the contents BETWEEN the two double quotes.
ooh...thanks. A little more Google-ing got me the syntax for ltrim. And hex codes (/x22 /x27) for single and double quotes. (escaping the double quotes wasn't working). Dunno if this is elegant or not, but it works for <coding idiot>me</coding idiot> foreach ($matches[0] as $match) { $match = ltrim($match,"option values="); $match = trim($match,"\x22\x27"); echo $match."<br>"; Code (markup): results are now: employee1.lastname firstname.mylastname