onlyican Posted February 5, 2010 Share Posted February 5, 2010 Hi all, I can never get my head around regex I have a string (Never would have guessed that bit for regex help would you) The string is the Content of a website. I want to try and find the following 1) What does it say under the meta tag <meta name="description" content="THIS BIT HERE BUT IT MIGHT BE NULL" /> 2) if the following exists and what the content is <meta name="revisit-after" content="5" /> 3) if an iframe is found and the source. This is a bit complex as meta could be META or MeTa (so I want case insensitive) They could use Single Quote or Double Quote The best method, if possible (I know its possible, if you guys could help) Get an array all all the meta tags on the website Split the name and Description Thus allowing me to check multiple things. Praise you lot, my head hurts just thinking about it Quote Link to comment https://forums.phpfreaks.com/topic/191044-regex-checks-preg_match/ Share on other sites More sharing options...
thebadbad Posted February 5, 2010 Share Posted February 5, 2010 You should be able to use get_meta_tags() for the META tags (else the comments on that page also contains regex solutions). You can check for iframes with this: //$html contains page source code if (preg_match_all('~<iframe\b[^>]+src\s?=\s?([\'"])(.+?)\1[^>]*>~is', $html, $matches)) { echo '<pre>' . print_r($matches[2], true) . '</pre>'; } else { echo 'No iframes found.'; } Quote Link to comment https://forums.phpfreaks.com/topic/191044-regex-checks-preg_match/#findComment-1007371 Share on other sites More sharing options...
onlyican Posted February 5, 2010 Author Share Posted February 5, 2010 Legend I was about to say it didnt work then I noticed the code said <frame.. not <iframe.. Simple change and it works, thanks Quote Link to comment https://forums.phpfreaks.com/topic/191044-regex-checks-preg_match/#findComment-1007387 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.