asmith3006 Posted January 15, 2009 Share Posted January 15, 2009 Hi, I have an HTML file with the code <input type="hidden" id="slotprod_1" value="WV013"> and I want to extract the value "WV013" from it (without the quotes). This is contained on a page with lots of other HTML. Is a regular expression the way to do this? Thanks Andrew. Quote Link to comment https://forums.phpfreaks.com/topic/140919-data-from-html-file-regex/ Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 sure: preg_match('/id="slotprod_1" value="(\d+)"/',$html,$matches); print $matches[1]; Quote Link to comment https://forums.phpfreaks.com/topic/140919-data-from-html-file-regex/#findComment-737648 Share on other sites More sharing options...
.josh Posted January 15, 2009 Share Posted January 15, 2009 would actually be \w not \d. Or [a-zA-Z0-9] if you want to be more specific. \d only matches numbers. Quote Link to comment https://forums.phpfreaks.com/topic/140919-data-from-html-file-regex/#findComment-737654 Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 would actually be \w not \d. Or [a-zA-Z0-9] if you want to be more specific. \d only matches numbers. oops...meant \w...thanks for catching that Quote Link to comment https://forums.phpfreaks.com/topic/140919-data-from-html-file-regex/#findComment-737657 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.