Pedro Posada | Regular Expression snippet preg_match_all
You can't request more than 20 challenges without solving them. Your previous challenges were flushed.

Regular Expression snippet preg_match_all

Posted on April 12, 2009 - 6:18pm
<< 20 of 54 >>

I was trying to extract the text of an html tag using regular expressions. It seems that preg_match_all is a good option to do this. I wanted to extract the taxonomy term name from within a views display template. I needed to embed a views inside another views. I needed to use part of the parent view's html as an argument for the nested view. I used preg_match_all to extract the term name from an html tag.

preg_match_all('/<title.*>(.+)<\/title.*>/uis', $contents, $matches);

I found the one that did the trick for me here: http://www.usenet-forums.com/php-language/23218-extracting-specified-htm...

 

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.