kevinkhan Posted January 1, 2011 Share Posted January 1, 2011 <input type=\"hidden\" autocomplete=\"off\" name=\"xhpc_composerid\" value=\"u269995_3\" \/> im trying to extract the value of the xhpc_composerid.. How do i go about doing it and what is wrong with this code preg_match('|<input[a-zA-Z =\\\"_]*name=\\\"xhpc_composerid\\\"[ ]*value=\\\"[0-9a-zA-Z]*\\\"[a-zA-Z =\\\"]*/>|', $page, $match); can anybody give me the correct solution and explain how it works Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted January 2, 2011 Share Posted January 2, 2011 You aren't accounting for the _ in the value. Quote Link to comment Share on other sites More sharing options...
.josh Posted January 2, 2011 Share Posted January 2, 2011 you also aren't actually capturing it. Need to wrap that part of the regex with parenthesis. Quote Link to comment Share on other sites More sharing options...
ignace Posted January 2, 2011 Share Posted January 2, 2011 You aren't accounting for the _ in the value. Since you wrote 0-9a-zA-Z and you also need to account for _ you'd be better off writing \w instead. Quote Link to comment Share on other sites More sharing options...
kevinkhan Posted January 2, 2011 Author Share Posted January 2, 2011 You aren't accounting for the _ in the value. Since you wrote 0-9a-zA-Z and you also need to account for _ you'd be better off writing \w instead. so can somebody write the full correct regex that i can use please.. sorry this is the next topic i have to learn... Quote Link to comment Share on other sites More sharing options...
kevinkhan Posted January 2, 2011 Author Share Posted January 2, 2011 anyone please? Quote Link to comment Share on other sites More sharing options...
.josh Posted January 2, 2011 Share Posted January 2, 2011 we told you the problem, pointed it out easy enough. You have what you need. We're hear to teach, not do your work for you. Quote Link to comment Share on other sites More sharing options...
sasa Posted January 3, 2011 Share Posted January 3, 2011 <?php $page ="<input type=\"hidden\" autocomplete=\"off\" name=\"xhpc_composerid\" value=\"u269995_3\" \/>"; preg_match('|<input\s[^>]*name="xhpc_composerid"\s[^>]*value="([^"]*)"[^>]*>|', $page, $match); print_r($match); ?> 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.